arm-tabular-parser/api/src/core/nats_callback.py

19 lines
790 B
Python
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

"""Обработчики сообщений NATS.
Каркас: доменный обработчик удалён. Consumer `recognition.result` (дедуп по recognition_job.result_msg_id,
маппинг JSON из S3 в document/osv_entry/financial_statement_*) реализуется в Срезе 0–2 по
docs/context/03-architecture.md. Для референса — reference-old-arm/api/src/core/nats_callback.py.
"""
from loguru import logger
from nats.aio.client import Client as NATS
from src.core.clients import S3Storage
def build_result_handler(nc: NATS, storage: S3Storage):
async def handler(msg):
logger.info("NATS message received. subject={subject}, size={size}", subject=msg.subject, size=len(msg.data))
await msg.ack()
return handler