topmesys
An embeddable topic-based message broker.
What it does
topmesys is an in-process publish/subscribe event bus for tokio applications. It lets loosely coupled parts of an application exchange messages through hierarchical topics instead of calling each other directly.
- Topic-based routing — messages carry a routing key like
orders.eu.created; consumers subscribe with patterns and only receive matching messages. - Flexible patterns — subscription topics support literal segments (
orders), wildcards (orders.*.created), selections (orders.[eu,us].paid) and tail matching (orders.*matchesorders.eu,orders.eu.created, ...). - Typestate lifecycle — invalid states are unrepresentable: an
EventTopicmust be turned into a routing key or a subscription pattern before use, and messages can only be sent to anEventBroker<Running>. - Batched, cancel-safe submission — the
EventEmittertrait submits single messages or batches through channel permits. - Graceful shutdown — stopping the broker drains all buffered messages and waits for
in-flight handlers to finish; stopping on Ctrl-C can be opted into with
with_ctrl_c_handling().
Matching messages are dispatched concurrently to all subscribed consumers; messages with no matching consumer are dropped silently.
Quick start
use Arc;
use mpsc;
use ;
// A consumer subscribes to a topic pattern and handles matching events.
// An emitter wraps a sender obtained from the running broker.
async
Complete, runnable scenarios live in examples/:
Benchmarks for topic parsing, subscription matching and end-to-end dispatch:
Development
ℹ️ Make sure just, git-cliff and cargo-llvm-cov are installed:
Common operations related to development and release can be found in the justfile. For an overview of available recipes, run:
License
Licensed under either of
- Apache License, Version 2.0 (LICENSE-APACHE or http://www.apache.org/licenses/LICENSE-2.0)
- MIT license (LICENSE-MIT or http://opensource.org/licenses/MIT)
at your option.
Contribution
Unless you explicitly state otherwise, any contribution intentionally submitted for inclusion in the work by you, as defined in the Apache-2.0 license, shall be dual licensed as above, without any additional terms or conditions.