rabbitmq implemented and tested

This commit is contained in:
2025-08-17 21:14:46 +03:00
parent 9543d136aa
commit 61529f7d94
43 changed files with 5433 additions and 315 deletions

View File

@@ -0,0 +1,18 @@
FROM python:3.12-slim
ENV PYTHONDONTWRITEBYTECODE=1 PYTHONUNBUFFERED=1
ENV PYTHONPATH=/app
WORKDIR /
COPY app/services/parser/mail/pyproject.toml ./
COPY app/services/parser/mail/README.md ./
COPY app/core ./app/core
COPY app/services/common/ ./app/services/common/
COPY app/services/parser/mail/ ./app/services/parser/mail/
RUN pip install --upgrade pip && pip install --no-cache-dir .
RUN mkdir -p /app/data
CMD ["python", "-m", "app.services.parser.mail.main"]

View File

@@ -0,0 +1,42 @@
import os
import asyncio
from app.services.common.service_base_async import ServiceBaseAsync
PRODUCE_BURST = int(os.getenv("PRODUCE_BURST", "10"))
PRODUCE_ONCE = os.getenv("PRODUCE_ONCE", "true").lower() == "true"
EVENT_TYPE = os.getenv("EVENT_TYPE", "db-mongo")
PROCESS_SEC = 10
async def produce(svc: ServiceBaseAsync):
await asyncio.sleep(PROCESS_SEC)
print(f"Parser Mail Producer produced {len([1,2])} events to '{svc.produce_key}'")
async def handle_db_publish(svc: ServiceBaseAsync, job):
await asyncio.sleep(PROCESS_SEC)
await svc.ack_current()
print("Parser Mail Consumer from db:", job)
async def handle_mongo_publish(svc: ServiceBaseAsync, job):
await asyncio.sleep(PROCESS_SEC)
await svc.ack_current()
print("Parser Mail Consumer from mongo:", job)
async def consume_default(svc: ServiceBaseAsync, job):
await asyncio.sleep(PROCESS_SEC)
print("Parser Mail Consumer default:", job)
return
if __name__ == "__main__":
svc = ServiceBaseAsync(
produce_fn=produce, consume_fn=consume_default,
handlers={"database.service.publish": handle_db_publish, "mongo.service.publish": handle_mongo_publish},
)
asyncio.run(svc.run())

View File

@@ -0,0 +1,37 @@
[build-system]
requires = ["setuptools>=61.0"]
build-backend = "setuptools.build_meta"
[project]
name = "dual-queue-services"
version = "0.1.0"
description = "Async dual queue system with Redis Streams and SQLite persistence"
readme = "README.md"
requires-python = ">=3.11"
authors = [
{ name = "Berkay Karatay", email = "karatay.berkay@gmail.com" }
]
dependencies = [
"aio-pika>=9.4.1",
"prometheus-client>=0.20.0",
"uvloop>=0.19.0"
]
[project.optional-dependencies]
dev = [
"pytest>=7.4",
"black>=23.0",
"isort>=5.12"
]
[tool.black]
line-length = 88
target-version = ["py311"]
[tool.isort]
profile = "black"
[tool.setuptools.packages.find]
where = ["app"]
include = ["app*"]