A3S Docs
A3S Event

Providers

EventProvider contracts, MemoryProvider, NATS JetStream, subjects, subscriptions, and custom backend rules.

Event Providers

a3s-event keeps application code on EventBus and EventProvider. Backends own transport and persistence details; the app keeps the same publish, subscribe, history, and health API.

Provider Matrix

ProviderFeatureUse casePersistenceDistribution
MemoryProvidercoretests, development, single-process deploymentsIn-process retained vector, lost on restartSingle process
NatsProvidernatsproduction multi-service eventingJetStream file or memory storageDistributed
Custom providerapp-ownedRedis, Kafka, database, or product-specific backendBackend-definedBackend-defined

Subject Model

Providers use dot-separated subjects:

events.<category>.<topic>[.<subtopic>...]

Examples:

SubjectMeaning
events.market.forex.usd_cnyMarket event for a forex pair.
events.system.deploy.gatewayGateway deployment event.
events.task.completedTask completion event.

Wildcard matching supports:

PatternMeaning
events.market.>All market events at any depth.
events.*.forexOne segment between events and forex.

EventProvider::build_subject(category, topic) defaults to {subject_prefix}.{category}.{topic}. category_subject(category) defaults to {subject_prefix}.{category}.>.

Event Envelope

An event contains an id, subject, category, event type, version, JSON payload, summary, source, timestamp, and string metadata. Untyped events are allowed: event_type defaults to empty and version defaults to 1.

Typed events use Event::typed(...), which lets the schema registry validate payloads by event_type and version.

Subscriptions

APISemantics
subscribe(pattern)Ephemeral subscription.
subscribe_durable(consumer, pattern)Durable subscription when supported by the provider.
next()Receive with provider-specific auto-ack behavior.
next_manual_ack()Receive a PendingEvent and explicitly ack() or nak().
history(pattern, limit)Fetch retained historical events.
unsubscribe(consumer)Remove durable subscription state where supported.
info() / health()Provider status and operational health.

The memory provider treats durable subscriptions like ephemeral subscriptions. NATS maps durable subscriptions to JetStream consumers.

NATS Configuration

NatsConfig includes:

FieldPurpose
urlNATS server URL.
token / credentials_pathOptional provider-native auth inputs.
stream_nameJetStream stream name.
subject_prefixPrefix used by stream subjects and default subject builders.
storagefile for persistence or memory for faster restart-volatile storage.
max_events, max_age_secs, max_bytesRetention limits.
connect_timeout_secs, request_timeout_secsProvider request timeouts.

Keep real provider credentials out of committed examples and load them from the deployment environment.

Custom Providers

Custom providers implement EventProvider and Subscription. Only subject_prefix() and name() are required for subject helpers; provider-specific publish and subscription options can be ignored or implemented as needed.

Use a custom provider when the product already standardizes on a transport, but still wants the A3S Event API, schema, DLQ, metrics, and routing abstractions.

On this page