Rust · topics · bounded queues
Riverbed is a message broker in Rust that delivers to every subscriber of a topic, matches wildcards like logs.*, and bounds every subscriber's queue so a slow one can never grow memory without limit. This is the real broker logic, running in your browser.
bounded queues, depth 8 each · drop-oldest policy · toggle "slow" on a subscriber, stop draining it, then publish to watch it fill and drop
The same rules as src/broker.rs and src/topic.rs, ported line for line into the page above.
A publish names a topic, a plain dot-separated string like orders.created.
A subscription pattern's * matches exactly one segment in that position, so logs.* matches logs.error but not logs.error.detail.
Every subscriber whose pattern matches gets the message enqueued, independent of every other subscriber.
Each subscriber has a max depth. A full queue never grows, it drops the oldest message or rejects the new one.
Delivered and dropped counts are tracked per subscriber and per topic, so backpressure is visible, not silent.
Removing a subscriber stops delivery to it immediately, its queue is discarded.
Why bounded queues matter
A single stalled subscriber can accumulate messages forever, and the broker's memory grows without limit until the process falls over.
Every subscriber has a fixed max depth. Past that, the broker drops the oldest queued message or rejects the new one, your choice per subscriber, and the queue simply stops growing.
Dropping is not free, a slow subscriber does lose messages. Riverbed counts every delivery and every drop, per subscriber and per topic, so the cost is a number you can see, not a surprise.
The scripted demo runs the same scenario as above, with a slow subscriber, prints delivered and dropped counts.
# subscribe, publish, watch a slow subscriber overflow
cargo run -- demo