Skip to main content

HookExecutor

Trait HookExecutor 

Source
pub trait HookExecutor: Send + Sync {
    // Required methods
    fn fire<'a>(
        &'a self,
        event: HookEvent,
        payload: Value,
    ) -> Pin<Box<dyn Future<Output = Result<HookDecision>> + Send + 'a>>;
    fn metrics(&self) -> ExecutorMetrics;
}
Expand description

Trait every executor implementation satisfies. fire is the single hot-path method G5 will iterate over when stitching chains together.

Send + Sync is mandatory: the registry hands out Arc<dyn HookExecutor> and the chain runner (G5) drives fires from arbitrary tokio worker threads.

Required Methods§

Source

fn fire<'a>( &'a self, event: HookEvent, payload: Value, ) -> Pin<Box<dyn Future<Output = Result<HookDecision>> + Send + 'a>>

Fire the hook for event with payload. Returns the child’s HookDecision or an ExecutorError on spawn / IO / decode / timeout failure.

This is async via the BoxFuture shape because trait objects + async fn in trait is still rough on stable (the auto-trait inference for Send doesn’t carry across the dyn boundary). BoxFuture<'_, Result<HookDecision>> is the same shape tower::Service settled on.

Source

fn metrics(&self) -> ExecutorMetrics

Snapshot of executor metrics. Surfaced by ai-memory doctor --tokens --hooks (see src/cli/doctor.rs).

Dyn Compatibility§

This trait is dyn compatible.

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

Implementors§