Skip to main content

EventHandler

Trait EventHandler 

Source
pub trait EventHandler: Send + Sync {
    // Required methods
    fn matches(&self, event: &ReceivedEvent) -> bool;
    fn handle<'life0, 'life1, 'async_trait>(
        &'life0 self,
        event: &'life1 ReceivedEvent,
    ) -> Pin<Box<dyn Future<Output = Result<HandlerResult>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait,
             'life1: 'async_trait;
    fn workflow_id(&self) -> &WorkflowId;
}
Expand description

Event handler trait for testable, composable handlers.

Handlers receive ReceivedEvent from the EventService subscriber and decide whether to dispatch workflows based on the event.

Required Methods§

Source

fn matches(&self, event: &ReceivedEvent) -> bool

Check if this handler should process the event.

Called for every event; should be fast (topic/type checking only).

Source

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

Process the event and return an action.

Only called if matches() returned true.

Source

fn workflow_id(&self) -> &WorkflowId

The workflow id this handler dispatches on behalf of.

Used by adapters to reconcile per-repo handlers: on a strict reload, handlers whose workflow id belongs to a repo being rescanned are dropped and rebuilt from the fresh workflow set, so a workflow that was rejected/deleted can no longer be triggered (#1432 fail-closed).

Implementors§