17 lines
528 B
Python
17 lines
528 B
Python
from backend.models.constants import NotificationChannel
|
|
from backend.infra.rabbitmq.async_publisher import AsyncMQPublisher
|
|
|
|
|
|
class NotificationPublisherService:
|
|
def __init__(self, channel: NotificationChannel) -> None:
|
|
self.mq_client = AsyncMQPublisher(channel.name)
|
|
|
|
async def bind(self):
|
|
await self.mq_client.bind(max_retries=5)
|
|
|
|
async def publish(self, message: str | bytes):
|
|
await self.mq_client.publish(message=message)
|
|
|
|
async def close(self):
|
|
await self.mq_client.close()
|