pub struct EventBusBuilder { /* private fields */ }Expand description
EventBus 构建器,提供流畅的配置 API。
§Example
ⓘ
use anycms_event::prelude::*;
use anycms_event::telemetry::TracingTelemetry;
use anycms_event::registry::EventRegistry;
let registry = Arc::new(EventRegistry::new());
let bus = EventBus::builder()
.capacity(2048)
.telemetry(TracingTelemetry)
.registry(registry)
.build();Implementations§
Source§impl EventBusBuilder
impl EventBusBuilder
Sourcepub fn registry(self, registry: Arc<EventRegistry>) -> Self
pub fn registry(self, registry: Arc<EventRegistry>) -> Self
设置自定义事件注册表。
如果不设置,构建时会自动创建一个空注册表。
Sourcepub fn execution_log(self, log: Arc<ExecutionLog>) -> Self
pub fn execution_log(self, log: Arc<ExecutionLog>) -> Self
设置执行日志。
执行日志记录事件发布和 Handler 执行的历史记录。
通常与 ExecutionLogTelemetry 一起使用。
Sourcepub fn retry_policy(self, policy: RetryPolicy) -> Self
pub fn retry_policy(self, policy: RetryPolicy) -> Self
设置 Handler 重试策略。
默认不重试(max_retries: 0)。
Sourcepub fn dead_letter_handler<H: DeadLetterHandler>(self, handler: H) -> Self
pub fn dead_letter_handler<H: DeadLetterHandler>(self, handler: H) -> Self
设置死信处理器。
当 Handler 重试耗尽后,将调用死信处理器。
Trait Implementations§
Auto Trait Implementations§
impl !RefUnwindSafe for EventBusBuilder
impl !UnwindSafe for EventBusBuilder
impl Freeze for EventBusBuilder
impl Send for EventBusBuilder
impl Sync for EventBusBuilder
impl Unpin for EventBusBuilder
impl UnsafeUnpin for EventBusBuilder
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more