pub struct EventBusBuilder { /* private fields */ }Expand description
Builder for configuring and constructing an EventBus.
§Examples
use std::time::Duration;
use jaeb::{EventBus, FailurePolicy};
let bus = EventBus::builder()
.buffer_size(512)
.handler_timeout(Duration::from_secs(5))
.max_concurrent_async(100)
.shutdown_timeout(Duration::from_secs(10))
.default_failure_policy(
FailurePolicy::default().with_max_retries(2),
)
.build();
bus.shutdown().await.unwrap();Implementations§
Source§impl EventBusBuilder
impl EventBusBuilder
Sourcepub fn buffer_size(self, size: usize) -> Self
pub fn buffer_size(self, size: usize) -> Self
Set the internal channel buffer size.
Defaults to 256.
Sourcepub fn handler_timeout(self, timeout: Duration) -> Self
pub fn handler_timeout(self, timeout: Duration) -> Self
Set the maximum time a single handler invocation may run before being treated as a failure.
When a handler exceeds this timeout, the attempt is treated as an error
and is eligible for retry or dead-lettering according to the listener’s
FailurePolicy.
By default there is no timeout.
Sourcepub fn max_concurrent_async(self, max: usize) -> Self
pub fn max_concurrent_async(self, max: usize) -> Self
Set the maximum number of async handler tasks that may execute concurrently.
When the limit is reached, new async tasks will wait for a permit before starting execution. Sync handlers are not affected.
By default there is no limit.
Sourcepub fn default_failure_policy(self, policy: FailurePolicy) -> Self
pub fn default_failure_policy(self, policy: FailurePolicy) -> Self
Set the default FailurePolicy applied to subscriptions that do not
specify one explicitly.
Sourcepub fn shutdown_timeout(self, timeout: Duration) -> Self
pub fn shutdown_timeout(self, timeout: Duration) -> Self
Set the maximum time EventBus::shutdown will wait for in-flight
async tasks to complete.
After this timeout, remaining tasks are aborted. By default, shutdown waits indefinitely.