Skip to main content

EventSink

Trait EventSink 

Source
pub trait EventSink: Send + Sync {
    // Required method
    fn emit<'life0, 'life1, 'async_trait>(
        &'life0 self,
        event: &'life1 KernelEvent,
    ) -> Pin<Box<dyn Future<Output = Result<(), KernelError>> + Send + 'async_trait>>
       where 'life0: 'async_trait,
             'life1: 'async_trait,
             Self: 'async_trait;

    // Provided method
    fn emit_record<'life0, 'life1, 'async_trait>(
        &'life0 self,
        record: &'life1 EventRecord,
    ) -> Pin<Box<dyn Future<Output = Result<(), KernelError>> + Send + 'async_trait>>
       where 'life0: 'async_trait,
             'life1: 'async_trait,
             Self: 'async_trait { ... }
}
Available on crate feature harness-kernel only.
Expand description

A destination for kernel events (spec 3.2 §7.6): the SSE stream, a channel notifier, an outbound webhook, the audit log.

§Example

use adk_kernel::{EventSink, KernelEvent};
use async_trait::async_trait;

struct Log;

#[async_trait]
impl EventSink for Log {
    async fn emit(&self, event: &KernelEvent) -> adk_kernel::Result<()> {
        tracing::info!(event.kind = event.name(), "kernel event");
        Ok(())
    }
}

Required Methods§

Source

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

Delivers event.

§Errors

Returns the sink’s delivery error; the bus logs it and carries on.

Provided Methods§

Source

fn emit_record<'life0, 'life1, 'async_trait>( &'life0 self, record: &'life1 EventRecord, ) -> Pin<Box<dyn Future<Output = Result<(), KernelError>> + Send + 'async_trait>>
where 'life0: 'async_trait, 'life1: 'async_trait, Self: 'async_trait,

Delivers record, the event with its cursor and time; the bus calls this. The default delivers the event alone through emit; a sink whose receiver orders or deduplicates by cursor, such as an outbound webhook, overrides it.

§Errors

Returns the sink’s delivery error; the bus logs it and carries on.

Dyn Compatibility§

This trait is dyn compatible.

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

Implementors§