Skip to main content

DispatchHook

Trait DispatchHook 

Source
pub trait DispatchHook: Send + Sync {
    // Required method
    fn on_dispatch<'life0, 'life1, 'async_trait>(
        &'life0 self,
        event: &'life1 Event,
    ) -> Pin<Box<dyn Future<Output = ()> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait,
             'life1: 'async_trait;
}
Expand description

Hook called after every successful verb dispatch (Issue #158).

Packs that want to observe real-time dispatch outcomes (e.g. brain pack updating its posteriors) implement this trait and register it via VerbRegistryBuilder::with_dispatch_hook. The hook is opt-in: when no hook is registered, dispatch incurs zero overhead.

The hook receives the synthesized Event that was built from the dispatch outcome — same representation used by the EventStore audit path — so brain pack’s EventFold can process it without extra conversion.

Required Methods§

Source

fn on_dispatch<'life0, 'life1, 'async_trait>( &'life0 self, event: &'life1 Event, ) -> Pin<Box<dyn Future<Output = ()> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait,

Called with the dispatch-outcome event after a successful pack dispatch.

Errors are logged via tracing::warn! and never propagated to the caller — the dispatch has already succeeded.

Implementors§