eventbus-core
Object-safe event-bus contract: traits, value types, and the generic
StreamBus<B: StreamBackend>. The contract layer of the
eventbus-contract facade.
Most users should depend on the facade crate instead — it bundles backends
and helpers behind feature flags. Depend on eventbus-core directly only
when you are building a custom StreamBackend, a custom Handler library,
or otherwise want the trait surface without any backend impl.
What's here
- Object-safe traits:
Bus,Publisher,Subscriber,Handler,Subscription,Delivery,DeliveryControl,DeliveryHandle,StreamBackend,Codec. Methods returnBoxFuture<'_, ...>so any combination ofArc<dyn Bus>/Box<dyn Handler>works for runtime dispatch. - Monomorphic shortcuts:
PublisherExt::publish_iter,SubscriberExt::subscribe_withfor callers that prefer static dispatch. - Value types:
Message,PublishOptions,SubscriptionConfig(+ builder),BatchOutcome/BatchError,EventBusError. - Newtype identifiers:
Topic,ConsumerGroup,ConsumerName,MessageId—#[repr(transparent)], parse-don't-validate. - Contract enums:
DeliveryGuarantee,AckMode,OrderingMode,ConsumerBalanceMode,OverflowStrategy,BackpressurePolicy. - Generic
StreamBus<B>+ the in-process bus plumbing (stream::{StreamBus, StreamBusOptions, ErrorObserver, ErrorScope}).
Object-safe contract
use Arc;
use ;
;
#
# dyn_dispatch;
DeliveryControl::ack/nack/retry consume Box<Self> — the type system
enforces "finalize at most once" at compile time.
Backends live in sibling crates
| Crate | What it provides |
|---|---|
eventbus-memory |
In-process StreamBackend for tests + dev |
eventbus-redis |
Redis Streams StreamBackend + JsonCodec |
eventbus-contract |
Facade re-exporting the published crates behind feature flags |
eventbus-outbox (transactional outbox + dispatcher traits) and
eventbus-integration (DDD integration-event helpers) live in the
workspace but are not published to crates.io until a reference
implementation lands (planned for 0.3.0).
Design notes
- Every public future is
Send; every public trait isdyn-safe. - Handler errors don't auto-retry under
AckMode::Manual— the handler owns the finalize decision.AutoOnHandlerSuccessis the opt-in auto-retry-on-error mode. publish_batchreturnsBatchOutcomewith oneResult<MessageId, _>per input — never fail-fast.- See
MIGRATION-0.2.mdif you're upgrading fromeventbus-contract0.1.
License
MIT