Trait ockam_core::Processor

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

    // Provided methods
    fn initialize<'life0, 'life1, 'async_trait>(
        &'life0 mut self,
        _context: &'life1 mut Self::Context
    ) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait,
             'life1: '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 Self: 'async_trait,
             'life0: 'async_trait,
             'life1: '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 Self: 'async_trait,
             'life0: 'async_trait,
             'life1: 'async_trait { ... }
}
Expand description

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

Required Associated Types§

source

type Context: Send + 'static

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

Provided Methods§

source

fn initialize<'life0, 'life1, 'async_trait>( &'life0 mut self, _context: &'life1 mut Self::Context ) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait,

Define the Processor Worker initialisation behaviour.

source

fn shutdown<'life0, 'life1, 'async_trait>( &'life0 mut self, _context: &'life1 mut Self::Context ) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait,

Define the Processor Worker shutdown behaviour.

source

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 Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait,

Define the Processor Worker background execution behaviour.

The process() callback function allows you to define worker behavior that will be executed.

If no .await is performed during process(), the execution will result in a busy loop.

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.

Always prefer async .await operations, as blocking operations can cause deadlocks.

Implementors§