Skip to main content

Worker

Trait Worker 

Source
pub trait Worker<Req, Resp>: Send + Sync {
    // Required methods
    fn id(&self) -> WorkerId;
    fn health(&self) -> WorkerHealth;
    fn dispatch(&self, req: Req) -> Result<Resp, WorkerError>;
}
Expand description

Trait every worker implements. Req and Resp are caller-defined; the future subprocess flavour will use a serde-friendly wire type as both parameters.

Required Methods§

Source

fn id(&self) -> WorkerId

Source

fn health(&self) -> WorkerHealth

Source

fn dispatch(&self, req: Req) -> Result<Resp, WorkerError>

Block until this request finishes. Errors propagate the engine’s failure mode without crashing the worker.

Dyn Compatibility§

This trait is dyn compatible.

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

Implementors§

Source§

impl<Req, Resp, F> Worker<Req, Resp> for InProcessWorker<Req, Resp, F>
where Req: Send, Resp: Send, F: Fn(Req) -> Result<Resp, WorkerError> + Send + Sync,