Brokers¶
A broker connects RustStream to a message transport. The framework ships an in-memory broker for development and tests; production brokers are separate crates you add as a dependency.
Handlers, routers, codecs, and middleware are broker-agnostic, so moving between brokers is a
one-line change at with_broker.
| Broker | Crate | Transport |
|---|---|---|
| Memory | ruststream (feature memory) |
in-process, for development and tests |
| NATS | ruststream-nats |
Core NATS and JetStream |
To implement a broker for another transport, see Broker authors.
Switching brokers¶
Every broker constructs synchronously and connects lazily (the runtime calls Broker::connect once
at startup), so the same handlers and routers run on any of them; only the broker construction
differs by one line inside with_broker.
Subscriptions that need broker-specific options (consumer groups, durable names) use that broker's
descriptor in the #[subscriber(..)] decorator; see
broker-specific descriptors.