Design
The core knows no broker: a broker crate implements its traits and owns every broker-specific setting.
The diagram as text
- Your service: #[subscriber] handlers; #[ruststream::app] builder
- ruststream: runtime: routing, dispatch, settlement, publishing; codecs: JSON, CBOR, MessagePack, or none chosen at compile time; features: memory broker, AsyncAPI, metrics, OpenTelemetry, testing; Broker, Subscriber, Publisher, sources, policies; capabilities: batches, transactions, request and reply, seeking
- Broker crates: ruststream-nats subjects, streams, policies, options, mount steps; ruststream-rdkafka topics, groups, policies, options, mount steps
- #[subscriber] handlers → runtime: routing, dispatch, settlement, publishing: mounted on
- ruststream-nats subjects, streams, policies, options, mount steps → Broker, Subscriber, Publisher, sources, policies: implements
- ruststream-rdkafka topics, groups, policies, options, mount steps → capabilities: batches, transactions, request and reply, seeking: implements
- ruststream-nats subjects, streams, policies, options, mount steps → async-nats: wraps
- ruststream-rdkafka topics, groups, policies, options, mount steps → rdkafka: wraps
The core depends on no broker client. Its required traits are the lifecycle of a connection, a
subscriber that is a Stream of deliveries, and a publisher. Batches, transactions, request and
reply, seeking and values a delivery already holds are capability traits a broker implements only
when its client has them.
A broker crate owns its vocabulary. The descriptor of a subscription form, the policy of a publisher, the per-message settings a publish carries and the mount steps that read the chain's settings all live there. The core has no broker-specific setting and no default for one.
The codec is a type: the codec a mounting names, or the default one the enabled feature selects. A service without a codec feature has no default, and a mounting that needs one does not compile.
Everything beyond the traits and the runtime is a cargo feature of the one crate: the memory broker, AsyncAPI, metrics, logging, OpenTelemetry, testing and the command line. Features only add, and none of them changes what another one does.