freeleaps-service-hub/apps/notification/backend/services/notification_publisher_service.py
2024-10-30 07:22:26 -07:00

17 lines
562 B
Python

from app.notification.backend.models.constants import NotificationChannel
from app.notification.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()