parser excel publish chain task build

This commit is contained in:
2025-08-18 18:31:29 +03:00
parent 61529f7d94
commit e4f6afbc93
9 changed files with 91 additions and 75 deletions

View File

@@ -1,10 +1,10 @@
import os
import json
import uuid
import asyncio
import fnmatch
import aio_pika
from pydantic import BaseModel
from core.utils import now_ms
from contextvars import ContextVar
from aio_pika.abc import AbstractIncomingMessage
@@ -20,6 +20,20 @@ class _MsgCtx(NamedTuple):
_MSG_CTX: ContextVar[_MsgCtx | None] = ContextVar("_MSG_CTX", default=None)
class Meta(BaseModel):
routing_key: str
attempts: int
exchange: str
class Job(BaseModel):
task_id: str
type: str
payload: dict
created_at: int
_meta: Meta
class ServiceBaseAsync:
"""
RabbitMQ tabanlı async servis iskeleti.
@@ -52,7 +66,7 @@ class ServiceBaseAsync:
self.queue_dlq = f"{self.queue_main}.dlq"
self.retry_delay_ms = int(os.getenv("RETRY_DELAY_MS", "5000"))
self.max_retries = int(os.getenv("MAX_RETRIES", "3"))
self.prefetch = int(os.getenv("PREFETCH", "16"))
self.prefetch = int(os.getenv("PREFETCH", "5"))
self.ignore_self = os.getenv("IGNORE_SELF_PRODUCED", "true").lower() == "true"
self.produce_fn = produce_fn
@@ -163,7 +177,6 @@ class ServiceBaseAsync:
attempts = int(msg.headers.get("x-attempts", 0))
except Exception:
pass
handler = self._resolve_handler(msg.routing_key) or self.consume_fn
meta = job.setdefault("_meta", {})
meta["routing_key"] = msg.routing_key