Skip to main content

Design

The core knows no broker: a broker crate implements its traits and owns every broker-specific setting.

The service, the broker-agnostic core, and broker crates that plug into its traitsYour serviceruststreamBroker crates#[subscriber]handlers#[ruststream::app]builderruntime: routing, dispatch,settlement, publishingcodecs: JSON, CBOR,MessagePack, or nonechosen at compile timefeatures: memory broker,AsyncAPI, metrics,OpenTelemetry, testingBroker, Subscriber,Publisher, sources,policiescapabilities: batches,transactions, requestand reply, seekingruststream-natssubjects, streams,policies, options,mount stepsruststream-rdkafkatopics, groups,policies, options,mount stepsasync-natsrdkafka
The diagram as text
  1. Your service: #[subscriber] handlers; #[ruststream::app] builder
  2. 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
  3. Broker crates: ruststream-nats subjects, streams, policies, options, mount steps; ruststream-rdkafka topics, groups, policies, options, mount steps
  4. #[subscriber] handlers → runtime: routing, dispatch, settlement, publishing: mounted on
  5. ruststream-nats subjects, streams, policies, options, mount steps → Broker, Subscriber, Publisher, sources, policies: implements
  6. ruststream-rdkafka topics, groups, policies, options, mount steps → capabilities: batches, transactions, request and reply, seeking: implements
  7. ruststream-nats subjects, streams, policies, options, mount steps → async-nats: wraps
  8. 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.