task services added

This commit is contained in:
2025-08-15 22:30:21 +03:00
parent 456203f5cf
commit 9543d136aa
38 changed files with 1065 additions and 0 deletions

View File

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

View File

@@ -0,0 +1,17 @@
import uuid
import asyncio
from app.services.common.service_base_async import ServiceBaseAsync
async def produce(service: ServiceBaseAsync):
print(f"Queue Reader Service up and running.")
while True:
await asyncio.sleep(1)
async def consume(service: ServiceBaseAsync, job: dict):
await asyncio.sleep(0.1)
print(f"Queue Sender Service up and running. Job: {job}")
if __name__ == "__main__":
asyncio.run(ServiceBaseAsync(produce, consume).run())

View File

@@ -0,0 +1,35 @@
[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 = [
"redis>=5.0.0",
"aiosqlite>=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*"]

View File

@@ -0,0 +1,16 @@
import asyncio
from services.service_base_async import ServiceBaseAsync
async def produce(service: ServiceBaseAsync):
fake_jobs = [{"action": "cleanup", "target": "old-tasks"}]
for job in fake_jobs:
await service.enqueue(job, "queue-maintenance")
async def consume(service: ServiceBaseAsync, job: dict):
print(f"[QUEUE CONTROL] İşleme alındı: {job}")
await asyncio.sleep(0.05)
if __name__ == "__main__":
asyncio.run(ServiceBaseAsync(produce, consume).run())