Expand description
§a3s-event
Pluggable event subscription, dispatch, and persistence for the A3S ecosystem.
§Overview
a3s-event provides a provider-agnostic API for publishing, subscribing to,
and persisting events. Swap backends (NATS, in-memory, Redis, Kafka, etc.)
without changing application code.
§Quick Start
use a3s_event::{EventBus, Event};
use a3s_event::provider::memory::MemoryProvider;
// Create an event bus with the in-memory provider
let bus = EventBus::new(MemoryProvider::default());
// Publish an event
let event = bus.publish(
"market",
"forex.usd_cny",
"USD/CNY broke through 7.35",
"reuters",
serde_json::json!({"rate": 7.3521}),
).await?;
println!("Published: {}", event.id);§Providers
- memory — In-memory provider for testing and single-process use
- nats — NATS JetStream for distributed, persistent event streaming
§Architecture
- EventProvider trait — core abstraction all backends implement
- EventBus — high-level API with subscription management
- Subscription trait — async event stream from any provider
- Event — provider-agnostic message envelope
Re-exports§
pub use broker::Broker;pub use broker::RouteResult;pub use broker::Trigger;pub use broker::TriggerFilter;pub use cloudevents::CloudEvent;pub use crypto::Aes256GcmEncryptor;pub use crypto::EncryptedPayload;pub use crypto::EventEncryptor;pub use dlq::DeadLetterEvent;pub use dlq::DlqHandler;pub use dlq::MemoryDlqHandler;pub use dlq::SinkDlqHandler;pub use error::EventError;pub use error::Result;pub use metrics::EventMetrics;pub use metrics::MetricsSnapshot;pub use provider::EventProvider;pub use provider::PendingEvent;pub use provider::ProviderInfo;pub use provider::Subscription;pub use schema::Compatibility;pub use schema::EventSchema;pub use schema::MemorySchemaRegistry;pub use schema::SchemaRegistry;pub use sink::CollectorSink;pub use sink::EventSink;pub use sink::FailingSink;pub use sink::InProcessSink;pub use sink::LogSink;pub use sink::TopicSink;pub use source::CronSource;pub use source::EventSource;pub use state::FileStateStore;pub use state::MemoryStateStore;pub use state::StateStore;pub use store::EventBus;pub use types::DeliverPolicy;pub use types::Event;pub use types::EventCounts;pub use types::PublishOptions;pub use types::ReceivedEvent;pub use types::SubscribeOptions;pub use types::SubscriptionFilter;pub use provider::memory::MemoryConfig;pub use provider::memory::MemoryProvider;pub use provider::nats::NatsClient;pub use provider::nats::NatsConfig;pub use provider::nats::NatsProvider;pub use provider::nats::NatsSubscription;pub use provider::nats::StorageType;
Modules§
- broker
- Broker/Trigger event routing
- cloudevents
- CloudEvents v1.0 envelope for A3S events
- crypto
- Payload encryption for events
- dlq
- Dead Letter Queue — handle events that exceed max delivery attempts
- error
- Error types for a3s-event
- metrics
- Observability metrics for the event bus
- provider
- Event provider trait — the core abstraction for event backends
- schema
- Event schema registry — validate and version event payloads
- sink
- Event sink — delivery targets for event routing
- source
- Event sources — adapters that produce events from external signals
- state
- EventBus state persistence
- store
- High-level event bus built on pluggable providers
- subject
- Subject matching utilities
- types
- Core event types for the a3s-event system