feat: creating chats for cards and clients, sending and deleting text messages

This commit is contained in:
2025-03-27 15:13:10 +04:00
parent a466e46f28
commit 2cdccb33ca
25 changed files with 928 additions and 7 deletions

29
external/kafka/consumer.py vendored Normal file
View File

@@ -0,0 +1,29 @@
from aiokafka import AIOKafkaConsumer
from aiokafka.errors import KafkaConnectionError
from backend.config import KAFKA_URL, KAFKA_CONSUMER_TOPIC
from backend.session import session_maker
from external.kafka.services.consumer_service import ConsumerService
consumer = AIOKafkaConsumer(
KAFKA_CONSUMER_TOPIC,
bootstrap_servers=KAFKA_URL,
)
async def consume_messages():
try:
await consumer.start()
except KafkaConnectionError as e:
print(e)
return
async with session_maker() as session:
consumer_service = ConsumerService(session)
print("started consuming messages")
try:
async for message in consumer:
await consumer_service.consume_message(message)
finally:
await consumer.stop()