Skip to main content

Module pool

Module pool 

Source
Expand description

Market-channel WebSocket connection pool for the Polymarket CLOB API.

PolymarketWebSocketClient stays a single-channel, single-connection primitive. This pool owns a set of market-channel connections (shards) and spreads unique asset subscriptions across them so no single connection carries more than ws_max_subscriptions assets. See WS_DEFAULT_SUBSCRIPTIONS for why that bound exists.

The pool grows lazily: it starts with one shard and opens another only when the current shards are full at subscribe time. A secondary shard closes once it owns no assets; the primary shard (which carries new-market discovery) always persists. Each shard replays only its own subscriptions on reconnect because that state lives inside its own PolymarketWebSocketClient. When custom features are enabled, every shard requests asset-scoped best-bid/ask events, while secondary shards discard global discovery and resolution events.

Structsยง

PolymarketMarketConnectionPool
A pool of market-channel WebSocket connections that shards asset subscriptions.
PolymarketMarketPoolHandle
Cloneable routing handle used from spawned subscription tasks.