mirror of
https://github.com/Screenly/Anthias.git
synced 2026-06-10 17:18:43 -04:00
Drops the second ZMQ leg — the viewer→server reply path — in favor of Redis BLPOP keyed by a UUID correlation ID. Same channel layer that PR1 moved the command bus onto, so the entire viewer messaging path now runs on Redis. Wire format extends the existing 'command¶meter' encoding: the 'current_asset_id' command (currently the only request-reply command) now carries the correlation ID in the parameter slot, and the viewer LPUSHes its JSON reply onto 'anthias.reply.<corr-id>' (with a 30s EXPIRE so unread replies don't accumulate). The server BLPOPs that key. This also fixes a latent correctness bug: ZmqCollector had no correlation, so concurrent /v1 ViewerCurrentAsset callers could mismatch replies. That hazard was masked today by uvicorn running single-worker; with Redis + correlation IDs, the reply path is now safe across concurrent callers. - settings.ZmqConsumer / ZmqCollector → settings.ReplySender / ReplyCollector (BLPOP). 'import zmq' drops out — pyzmq itself is removed in the next commit. - lib.errors.ZmqCollectorTimeoutError → ReplyTimeoutError (the only catch site is implicit — it bubbles to a 500 — so the rename is mechanical). - viewer/__init__.py: send_current_asset_id_to_server takes a correlation ID and uses ReplySender. The 'current_asset_id' command handler in the dispatch table threads the parameter (now the corr ID) into the function call. - api/views/v1.py ViewerCurrentAssetViewV1: generates a UUID, sends it with the command, BLPOPs on it. - api/tests/test_v1_endpoints.py: ZmqCollector mock → ReplyCollector; side_effect signature relaxed to '*_' since recv_json now takes two positional args (corr, timeout_ms). - stubs/redis-stubs/client.pyi: add rpush() and blpop() narrowed to decode_responses=True return shapes (the rest of the stub follows the same convention). Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>