feat: Add Bounded Queues With Backpressure Signaling - #10
Merged
Conversation
Finite ready-queue capacity with reject-on-full, plus high/low watermark hysteresis so producers can pause and resume without dropping work the queue already accepted.
Sync ack still sits inside deliver's handler try/catch. Flow notifications from that path were swallowed after the entry settled. Defer applyFlow until pumping is false, and cover the consume-drain listener throw.
ThomasHartDev
force-pushed
the
thomas/feat/backpressure
branch
from
September 4, 2026 19:28
2da3eb2 to
7d4c200
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
The work queue used to grow its ready list without a limit. Slow or missing consumers could pile up forever and the producer had no way to find out.
This adds a finite ready-queue capacity. enqueue throws QueueFullError when the backlog is full, and tryEnqueue returns { accepted: false } so a caller can wait. A WatermarkGate watches ready depth: pause at or above high, resume at or below low, hold the last state in the open band. Occupancy bouncing between high and high-1 only stays paused when low is at most high-2. Default bounds for capacity 2 are high=2 and low=1, so 2 vs 1 does flip. Redelivery of a message that already got in is still allowed to sit above capacity. Prefetch still caps in-flight.
Flow notifications run after the pump is idle so a listener throw on consume/ack is not swallowed by deliver's handler try/catch. enqueue can still throw a listener error after the payload is already on ready: treat that as notify-after-accept, not reject-and-retry.
Closes #9