freeleaps-service-hub/app/notification/backend/services/notification_publisher_service.py

17 lines
545 B
Python

from app.notification.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()