Rust · topics · bounded queues

Publish once,
see every queue react.

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.

Try the demo View on GitHub
logs.error logs.info orders.created orders.shipped

bounded queues, depth 8 each · drop-oldest policy · toggle "slow" on a subscriber, stop draining it, then publish to watch it fill and drop

How it works

The same rules as src/broker.rs and src/topic.rs, ported line for line into the page above.

1

Topics

A publish names a topic, a plain dot-separated string like orders.created.

2

Wildcard match

A subscription pattern's * matches exactly one segment in that position, so logs.* matches logs.error but not logs.error.detail.

3

Delivery

Every subscriber whose pattern matches gets the message enqueued, independent of every other subscriber.

4

Bounded queue

Each subscriber has a max depth. A full queue never grows, it drops the oldest message or rejects the new one.

5

Counters

Delivered and dropped counts are tracked per subscriber and per topic, so backpressure is visible, not silent.

6

Unsubscribe

Removing a subscriber stops delivery to it immediately, its queue is discarded.

Why bounded queues matter

A slow subscriber is its own problem, not the broker's.

Unbounded queue

A single stalled subscriber can accumulate messages forever, and the broker's memory grows without limit until the process falls over.

Riverbed's bounded queue

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.

The tradeoff, made visible

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.

Run it from the command line.

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