pub trait Processor: Send + 'static {
    type Context: Send + 'static;

    fn initialize<'life0, 'life1, 'async_trait>(
        &'life0 mut self,
        _context: &'life1 mut Self::Context
    ) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>>
    where
        'life0: 'async_trait,
        'life1: 'async_trait,
        Self: 'async_trait
, { ... } fn shutdown<'life0, 'life1, 'async_trait>(
        &'life0 mut self,
        _context: &'life1 mut Self::Context
    ) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>>
    where
        'life0: 'async_trait,
        'life1: 'async_trait,
        Self: 'async_trait
, { ... } fn process<'life0, 'life1, 'async_trait>(
        &'life0 mut self,
        _context: &'life1 mut Self::Context
    ) -> Pin<Box<dyn Future<Output = Result<bool>> + Send + 'async_trait>>
    where
        'life0: 'async_trait,
        'life1: 'async_trait,
        Self: 'async_trait
, { ... } }
Expand description

Defines an interface for Ockam Workers that need to continuously perform background operations.

Required Associated Types

The Ockam API Context and other resources available for the processor during processing.

Provided Methods

Define the Processor Worker initialisation behaviour.

Define the Processor Worker shutdown behaviour.

Define the Processor Worker background execution behaviour.

The process() callback function allows you to define worker behaviour that will be executed at regular intervals.

It’s important to not block this function for long periods of time as it is co-operatively scheduled by the underlying async runtime and will block all other Ockam Node operations until it returns.

When in doubt, prefer async .await operations where they are available.

Implementors