feat(polymarket): subscription monitoring and connection recycling

The exchange can fail without telling us, and first one wins hides a
subscription gone quiet on one of a symbol's two connections.

- A connection that receives nothing for 30 s, not even the keepalive's
  answer, reconnects.
- Each book thread counts a symbol's changes per connection every minute:
  a subscription with none against three or more on the other is
  resubscribed, and moved to another connection if it stays quiet.
- The orchestrator recycles one connection at a time, each about hourly,
  and never while another connection is down or just back.
- A reconnect's opening book of a symbol unchanged for 10 s is judged like
  a resync's answer: one newer than ours that differs shows a symbol quiet
  on both connections, written as a Snapshot and logged as a loss.
This commit is contained in:
pascal committed 2026-11-11 17:42:27 +00:00
1 parent 02747b882f
commit 480ee3ad2d
10 files changed
+1346 -102

No files matched your search

+21
View File
@@ -71,6 +71,27 @@ verified and until a fresh book says where it stands.
**Split**:
Moving half the markets off a connection the exchange keeps closing.
**Quiet**:
Said of a symbol's subscription on a connection that is up, while the
exchange has stopped sending that symbol's changes there. Nothing tells us:
it has to be looked for.
_Avoid_: Stale, dead (a connection can be fine while one of its
subscriptions is quiet)
**Resubscribe**:
To unsubscribe a symbol on one connection and subscribe it again there, which
makes the exchange start its subscription afresh. A resync is a resubscribe
whose book we asked for.
**Silent**:
Said of a connection that is open but delivers nothing at all, not even the
answer to its keepalive.
**Recycle**:
To close a working connection on purpose and reconnect it with the same
symbols, to shed what has gone wrong on the exchange's side of it.
_Avoid_: Restart, rotate
**Receive time**:
When a message came off the socket, by the local clock.
_Avoid_: Arrival time, local timestamp