Skip to main content

NotificationHook

Trait NotificationHook 

Source
pub trait NotificationHook: Send + Sync {
    // Required methods
    fn label(&self) -> &str;
    fn run<'life0, 'async_trait>(
        &'life0 self,
        sink: TriggerSink,
    ) -> Pin<Box<dyn Future<Output = Result<(), HookError>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait;
    fn status(&self) -> NotificationHookStatus;
}
Expand description

Long-running source adapter trait. One instance per configured source.

Implementations live in crates/harness (or downstream crates) — the runtime crate must stay transport-agnostic. The runtime invokes run once per hook on a dedicated task; the task is expected to live until the supervisor cancels it (Tokio cancellation token), at which point run should return promptly.

Required Methods§

Source

fn label(&self) -> &str

Stable label used in NotificationHookStatus, /triggers hooks UI rows, and per-source counters. Should be short and human-readable (e.g. "mcp:filesystem", "cron").

Source

fn run<'life0, 'async_trait>( &'life0 self, sink: TriggerSink, ) -> Pin<Box<dyn Future<Output = Result<(), HookError>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

Drive the source. Push triggers into sink as they arrive. Return Ok(()) on clean shutdown or Err on protocol / auth failure; the supervisor records the failure on the hook status and may restart per its backoff policy.

Source

fn status(&self) -> NotificationHookStatus

Snapshot for status views (/triggers hooks, theway status). Called frequently; the implementation should keep this cheap (atomic loads or parking_lot::Mutex).

Dyn Compatibility§

This trait is dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementors§