Add some environment variables to control debug output

This commit is contained in:
2022-10-21 07:20:30 +01:00
parent e32b330ef4
commit f774f4c2d2
2 changed files with 30 additions and 13 deletions

10
db.py
View File

@@ -1,14 +1,19 @@
import random
from os import getenv
import aioredis
import orjson
import redis
# Kafka
from aiokafka import AIOKafkaProducer
import redis
import util
trues = ("true", "1", "t", True)
MONOLITH_KAFKA_ENABLED = getenv("MONOLITH_KAFKA_ENABLED", "false").lower() in trues
# KAFKA_TOPIC = "msg"
log = util.get_logger("db")
@@ -44,6 +49,9 @@ KEYNAME = "queue"
async def store_kafka_batch(data):
if not MONOLITH_KAFKA_ENABLED:
log.info(f"Not storing Kafka batch of length {len(data)}, Kafka is disabled.")
return
# log.debug(f"Storing Kafka batch of {len(data)} messages")
producer = AIOKafkaProducer(bootstrap_servers="kafka:9092")
await producer.start()