Removed HVAC handler and changed deployment to Kubernetes
This commit is contained in:
1 parent
aab311dc86
commit
5bd757e875
6 files changed
+20
-63
No files matched your search
+11
-7
@@ -1,13 +1,17 @@
|
||||
import pika
|
||||
from typing import Dict
|
||||
from secret_handler import return_credentials
|
||||
import ssl
|
||||
from hvac_handler import get_secret
|
||||
import json
|
||||
import time
|
||||
import sys
|
||||
import os
|
||||
|
||||
rmq_username = get_secret("secret/api-internal/rmq", "username")
|
||||
rmq_password = get_secret("secret/api-internal/rmq", "password")
|
||||
rmq_username = return_credentials("/etc/secrets/rmq_username")
|
||||
rmq_password = return_credentials("/etc/secrets/rmq_password")
|
||||
rmq_host = os.getenv("BACKEND_API_INTERNAL_RMQ_HOST","localhost")
|
||||
rmq_vhost = os.getenv("BACKEND_API_INTERNAL_RMQ_VHOST","app_notifications")
|
||||
rmq_exchange = os.getenv("BACKEND_API_INTERNAL_RMQ_EXCHANGE","app_notifications")
|
||||
|
||||
MAX_RETRIES = 5
|
||||
RETRY_DELAY = 5
|
||||
@@ -18,21 +22,21 @@ def send_message_to_rmq(user_id: int, message: Dict):
|
||||
context.check_hostname = False
|
||||
ssl_options = pika.SSLOptions(context)
|
||||
conn_params = pika.ConnectionParameters(
|
||||
host="localhost",
|
||||
host=rmq_host,
|
||||
port=5671,
|
||||
ssl_options=ssl_options,
|
||||
credentials=credentials,
|
||||
virtual_host="app_notifications"
|
||||
virtual_host=rmq_vhost
|
||||
)
|
||||
|
||||
for attempt in range(1, MAX_RETRIES + 1):
|
||||
try:
|
||||
connection = pika.BlockingConnection(conn_params)
|
||||
channel = connection.channel()
|
||||
channel.exchange_declare(exchange="app_notifications", exchange_type="topic", durable=True)
|
||||
channel.exchange_declare(exchange=rmq_exchange, exchange_type="topic", durable=True)
|
||||
channel.confirm_delivery()
|
||||
channel.basic_publish(
|
||||
exchange='app_notifications',
|
||||
exchange=rmq_exchange,
|
||||
routing_key=f"notify.user.{user_id}",
|
||||
body=json.dumps(message),
|
||||
properties=pika.BasicProperties(
|
||||
|
||||
Reference in new issue
Block a user