Yangi notification model va RabbitMQ ulanish funksiyalari qo'shildi
This commit is contained in:
1
notification/internal/models/fcm.go
Normal file
1
notification/internal/models/fcm.go
Normal file
@@ -0,0 +1 @@
|
|||||||
|
package models
|
||||||
21
order/core/utils/notification.py
Normal file
21
order/core/utils/notification.py
Normal file
@@ -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')
|
||||||
15
order/core/utils/rabbitmq.py
Normal file
15
order/core/utils/rabbitmq.py
Normal file
@@ -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
|
||||||
|
|
||||||
@@ -10,7 +10,6 @@ CACHES = {
|
|||||||
|
|
||||||
CACHE_MIDDLEWARE_SECONDS = env("CACHE_TIMEOUT")
|
CACHE_MIDDLEWARE_SECONDS = env("CACHE_TIMEOUT")
|
||||||
|
|
||||||
|
|
||||||
CACHEOPS_REDIS = env.str("REDIS_URL")
|
CACHEOPS_REDIS = env.str("REDIS_URL")
|
||||||
CACHEOPS_DEFAULTS = {
|
CACHEOPS_DEFAULTS = {
|
||||||
"timeout": env.str("CACHE_TIMEOUT"),
|
"timeout": env.str("CACHE_TIMEOUT"),
|
||||||
|
|||||||
Reference in New Issue
Block a user