Skip to main content

WorkerHandle

Trait WorkerHandle 

Source
pub trait WorkerHandle: Send + 'static {
    // Required methods
    fn id(&self) -> u32;
    fn ready<'life0, 'async_trait>(
        &'life0 mut self,
    ) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait;
    fn execute<'life0, 'life1, 'async_trait>(
        &'life0 mut self,
        method: &'life1 str,
        payload: Value,
    ) -> Pin<Box<dyn Future<Output = Result<Value>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait,
             'life1: 'async_trait;
    fn terminate<'life0, 'async_trait>(
        &'life0 mut self,
    ) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait;
}
Expand description

A handle to a spawned worker.

The pool dispatches requests via execute and controls lifecycle via ready and terminate.

Required Methods§

Source

fn id(&self) -> u32

Worker identifier (thread ID, PID, or synthetic).

Source

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

Wait for the worker to signal readiness. Returns once the worker has booted and is ready to accept requests.

Source

fn execute<'life0, 'life1, 'async_trait>( &'life0 mut self, method: &'life1 str, payload: Value, ) -> Pin<Box<dyn Future<Output = Result<Value>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait,

Execute a single request: send structured data, receive result.

Source

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

Terminate the worker. Implementations should signal shutdown and wait for the worker to exit.

Implementors§