Files
buryan-infra/ops/events/pipeline.py
T
architect e6fc2cb3aa
lint / hygiene (pull_request) Failing after 42s
standard / check (pull_request) Successful in 21s
lint / hygiene (push) Failing after 37s
standard / check (push) Successful in 29s
[STAGE2] Adapters: Audit360 + Jellyfin + Seerr
2026-11-27 11:20:05 +03:00

45 lines
1.2 KiB
Python

#!/usr/bin/env python3
"""Durable Stage 2 pipeline: adapter → outbox → JetStream → idempotent consumer."""
import asyncio
import signal
import time
from adapters import audit360, jellyfin_media, seerr_requests
from event_store import connect, init
from nats_relay import consume_once, relay_once
STOP = False
def _stop(*_):
global STOP
STOP = True
def main():
signal.signal(signal.SIGTERM, _stop)
signal.signal(signal.SIGINT, _stop)
conn = connect()
init(conn)
conn.close()
print("events-pipeline start", flush=True)
while not STOP:
try:
conn = connect()
init(conn)
emitted = audit360(conn) + jellyfin_media(conn) + seerr_requests(conn)
conn.close()
relayed = asyncio.run(relay_once())
consumed = asyncio.run(consume_once(timeout=2))
print("tick emitted=%s relayed=%s consumed=%s" % (emitted, relayed, consumed), flush=True)
except Exception as e:
print("tick_error", str(e)[:300], flush=True)
for _ in range(5):
if STOP:
break
time.sleep(1)
if __name__ == "__main__":
main()