fix(binance): buffer streams before initial snapshots - #127
Conversation
📝 WalkthroughWalkthroughWebsocket session startup now waits for all expected streams to connect before issuing REST snapshot requests. Connection acknowledgments feed a readiness gate, which then runs the existing snapshot pipeline. Session metadata uses the computed stream count, and an async test verifies ordering and shutdown. ChangesSnapshot startup coordination
Estimated code review effort: 3 (Moderate) | ~20 minutes Sequence Diagram(s)sequenceDiagram
participant Session
participant WebsocketStreams
participant ReadinessGate
participant SnapshotProducer
Session->>WebsocketStreams: Start expected websocket tasks
WebsocketStreams->>ReadinessGate: Send connection acknowledgments
ReadinessGate->>SnapshotProducer: Start after all acknowledgments
SnapshotProducer-->>Session: Emit snapshots and InitialSnapshotsComplete
Possibly related PRs
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
|
@coderabbitai review |
✅ Action performedReview finished.
|
Change contract
Start initial REST snapshot acquisition only after every required Binance WebSocket stream has connected, so startup depth events can be buffered before reconciliation.
Out of scope
Dependency / merge order
Depends only on merged PR #126 and current
main; merge this PR before generating the Finance/Crypto research artifact.Focused validation
snapshots_wait_until_every_websocket_stream_is_connectedasserts zero REST requests after only one of two required streams is connected. GitHub Linux run29635261468failed at red commit1cb5853ebecause the barrier did not exist.075e3f5c76aa139168c02ec383aaacd0f768114a; CodeRabbit completed with no actionable findings.8427115579, binary SHA-25677922320fc07aebc1af4c1d3d7f9fd830b1528b4cec9739f3bcd03ecfad02505, cloud self-test passed.20260718t080031zproduced 10 consecutive 60-second segments in one session (18c35374da096517-197772), BTCUSDT/SOLUSDT both bridged, every data/manifest SHA verified, zero sequence gaps, zero internal reconnects, zero process restarts, and production PIDs/restart counters/invocation IDs unchanged.1bf1253170bb6fc3597a0a5ab71cfa42dfa653e80e77687a30bb01a85094f45f.Rollout / rollback impact
Candidate-only validation completed; no production service or symlink changed. Rollback is the previous immutable collector binary; no state migration is required. Production cutover remains a separate gate and is not part of this PR.