Commit 9ead592
committed
feat(rfq): debounce and rate-limit levels republish after quote expiry
- Add `LEVELS_REPUBLISH_COALESCE` (25ms) debounce to batch `quoteExpired` frames
into a single levels flush, preventing reconnect replay from emitting one book
per expiry and collapsing the cadence to ~2s
- Implement rate window tracking to respect venue's 40/s `admitMessage` cap across
levels frames, quote replies, and expiry flushes in a 1s rolling window
- Track `pending_republish` set of corridors with dropped quotes; arm trailing
flush only when known corridors expire, not on every frame
- Skip trailing flush when dark feeds exist (no ready frames) to avoid wasting
budget, but keep debounce armed to retry when feed recovers
- Defer trailing flush if 40/s budget is exhausted; schedule retry when oldest
batches age out of the 1s window
- Skip interval tick when trailing flush is pending or recently fired (within last
1s) to prevent doubling book depth in the same second; reschedule tick to end of
expiry window to avoid phase drift
- Drop emitted corridors from `pending_republish` after successful send to prevent
resending on next expiry and growing the set unboundedly
- Use `biased` select to prioritize inbound over interval tick so `quoteExpired`
beats the timer until trailing debounce fires, fixing starvation where books
dropped after the venue's 1s republish wait completed
- Add `Reservations::corridor()` peek method to identify which corridor a quote
belongs to, enabling targeted expiry flushes instead of full republish
- Add comprehensive tests covering rate window mechanics, debounce timers, dark
feed detection, and interval suppression logic1 parent 0f8decf commit 9ead592
6 files changed
Lines changed: 572 additions & 24 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1 | | - | |
| 1 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1 | | - | |
| 1 | + | |
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1 | 1 | | |
2 | 2 | | |
3 | | - | |
| 3 | + | |
4 | 4 | | |
5 | 5 | | |
6 | 6 | | |
| |||
0 commit comments