Trait ockam_core::Processor
source · 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
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§
Provided Methods§
sourcefn 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 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.
sourcefn 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 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.
sourcefn 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,
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
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.