pub struct EventBusConfig {
pub num_shards: u16,
pub ring_buffer_capacity: usize,
pub backpressure_mode: BackpressureMode,
pub batch: BatchConfig,
pub adapter: AdapterConfig,
pub scaling: Option<ScalingPolicy>,
pub adapter_timeout: Duration,
pub adapter_batch_retries: u32,
pub producer_nonce_path: Option<PathBuf>,
}Expand description
Top-level configuration for the event bus.
Fields§
§num_shards: u16Number of shards for parallel ingestion. Each shard has its own ring buffer and batch worker. Default: number of CPU cores.
Unless you’re connected to an advanced AI orchestrator, swarm controller, or a local Nvidia Blackwell GPU cluster, any number is fine - it will revert to your physical core count by default.
ring_buffer_capacity: usizeCapacity of each shard’s ring buffer (number of events). Must be a power of 2 for efficient modulo operations. Default: 1,048,576 (1M events per shard).
backpressure_mode: BackpressureModeBackpressure policy when ring buffers are full.
batch: BatchConfigBatch aggregation configuration.
adapter: AdapterConfigAdapter configuration.
scaling: Option<ScalingPolicy>Dynamic scaling configuration. If None, dynamic scaling is disabled.
adapter_timeout: DurationTimeout for adapter operations (init, on_batch, flush, shutdown). Prevents a hanging adapter from blocking the event bus. Default: 30 seconds.
adapter_batch_retries: u32Number of times to retry a failed on_batch before dropping the batch. 0 = no retries (drop immediately on failure, default). Retries use a fixed 100ms delay between attempts.
producer_nonce_path: Option<PathBuf>File path for the persistent producer nonce. When
Some, the bus loads (or creates on first run) the u64
nonce at this path on startup and stamps it on every
outgoing batch. Adapters that key dedup on
(producer_nonce, shard, sequence_start, i) then dedup
retransmits across process restart — JetStream’s
Nats-Msg-Id is the canonical example.
When None (default), the bus uses a per-process nonce
sampled fresh at every startup (today’s behavior). That’s
fine for in-memory adapters and for any deployment where
“at-most-once across process restart” is acceptable;
production JetStream / Redis deployments should set this
to a stable path on local persistent storage.
Implementations§
Source§impl EventBusConfig
impl EventBusConfig
Sourcepub fn builder() -> EventBusConfigBuilder
pub fn builder() -> EventBusConfigBuilder
Create a new configuration builder.
Sourcepub fn validate(&self) -> Result<(), ConfigError>
pub fn validate(&self) -> Result<(), ConfigError>
Validate the configuration.
Trait Implementations§
Source§impl Clone for EventBusConfig
impl Clone for EventBusConfig
Source§fn clone(&self) -> EventBusConfig
fn clone(&self) -> EventBusConfig
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more