diff --git a/notification/internal/models/fcm.go b/notification/internal/models/fcm.go new file mode 100644 index 0000000..2640e7f --- /dev/null +++ b/notification/internal/models/fcm.go @@ -0,0 +1 @@ +package models diff --git a/order/core/utils/notification.py b/order/core/utils/notification.py new file mode 100644 index 0000000..5a84500 --- /dev/null +++ b/order/core/utils/notification.py @@ -0,0 +1,21 @@ +# rabbitmq.py + +from kombu import Exchange, Producer +from .rabbitmq import get_connection + +_channel = None +_exchange = Exchange('notification', type='direct') +_producer = None + +def get_producer(): + global _producer, _channel + if _producer is None: + conn = get_connection() + _channel = conn.channel() + _producer = Producer(_channel, exchange=_exchange, routing_key="notification") + return _producer + + +def send_notification(message: dict): + producer = get_producer() + producer.publish(message, serializer='json') diff --git a/order/core/utils/rabbitmq.py b/order/core/utils/rabbitmq.py new file mode 100644 index 0000000..890dbc5 --- /dev/null +++ b/order/core/utils/rabbitmq.py @@ -0,0 +1,15 @@ +# rabbitmq.py + +from kombu import Connection + +rabbit_url = 'amqp://guest:guest@rabbitmq:5672/' +_connection = None + + +def get_connection(): + global _connection + if _connection is None or not _connection.connected: + _connection = Connection(rabbit_url) + _connection.ensure_connection(max_retries=3) + return _connection + diff --git a/user/config/conf/cache.py b/user/config/conf/cache.py index cd724b5..95371c9 100644 --- a/user/config/conf/cache.py +++ b/user/config/conf/cache.py @@ -10,7 +10,6 @@ CACHES = { CACHE_MIDDLEWARE_SECONDS = env("CACHE_TIMEOUT") - CACHEOPS_REDIS = env.str("REDIS_URL") CACHEOPS_DEFAULTS = { "timeout": env.str("CACHE_TIMEOUT"),