Skip to content

feat(ws): add subscribe_all_market for single-receiver all-event stream#292

Open
yovanoc wants to merge 3 commits intoPolymarket:mainfrom
yovanoc:feat/subscribe-all-market
Open

feat(ws): add subscribe_all_market for single-receiver all-event stream#292
yovanoc wants to merge 3 commits intoPolymarket:mainfrom
yovanoc:feat/subscribe-all-market

Conversation

@yovanoc
Copy link
Copy Markdown

@yovanoc yovanoc commented Mar 19, 2026

Adds Client::subscribe_all_market(asset_ids) — returns Stream<Item = Result<WsMessage>> with all market event types from a single broadcast receiver.

Thin wrapper around subscribe_market_with_options(ids, true). Enables custom_feature_enabled.

Problem: calling multiple subscribe_* methods (orderbook + ltp + bba + tick_size + ...) creates N broadcast receivers on the same channel. Each gets a copy of every message. At 6+ receivers the broadcast overflows.

Fix: one call, one receiver, all events. Consumer dispatches by variant.


Note

Medium Risk
Adds a new public subscription API that changes how consumers may multiplex market events; main risk is behavioral/compatibility issues around receiving and dispatching all WsMessage variants and ensuring the custom_feature_enabled flag is set as expected.

Overview
Adds Client::subscribe_all_market(asset_ids) to return a single Stream<Item = Result<WsMessage>> for all market channel events, using subscribe_market_with_options(..., true) to enable custom_feature_enabled and avoid multiple broadcast receivers.

Extends websocket tests to assert the subscription request includes "custom_feature_enabled":true and that the unified stream can receive both WsMessage::Book and WsMessage::BestBidAsk events.

Written by Cursor Bugbot for commit 40c28e2. This will update automatically on new commits. Configure here.

Adds Client::subscribe_all_market(asset_ids) that returns a
Stream<Item = Result<WsMessage>> with ALL market event types
(Book, PriceChange, LastTradePrice, TickSizeChange, BestBidAsk,
NewMarket, MarketResolved) filtered by asset_id.

Uses subscribe_market_with_options(ids, true) internally — one
broadcast receiver instead of N per event type. Enables
custom_feature_enabled on the connection.

This avoids broadcast channel overflow when consumers need multiple
event types: instead of 6 subscribe_* calls creating 6 receivers,
one subscribe_all_market call creates 1 receiver.
@codecov
Copy link
Copy Markdown

codecov Bot commented Mar 19, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 85.47%. Comparing base (8c98bb8) to head (40c28e2).

Additional details and impacted files
@@            Coverage Diff             @@
##             main     #292      +/-   ##
==========================================
+ Coverage   85.45%   85.47%   +0.02%     
==========================================
  Files          32       32              
  Lines        5121     5129       +8     
==========================================
+ Hits         4376     4384       +8     
  Misses        745      745              
Flag Coverage Δ
rust 85.47% <100.00%> (+0.02%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant