Trait mesh_worker::Worker
source · pub trait Worker: 'static + Sized {
type Parameters: 'static + Send;
type State: MeshPayload;
const ID: WorkerId<Self::Parameters>;
// Required methods
fn new(parameters: Self::Parameters) -> Result<Self>;
fn restart(state: Self::State) -> Result<Self>;
fn run(self, recv: Receiver<WorkerRpc<Self::State>>) -> Result<()>;
}
Expand description
Trait implemented by workers.
Required Associated Types§
sourcetype Parameters: 'static + Send
type Parameters: 'static + Send
Parameters passed to launch the worker. Used with Worker::new
.
For this worker to be spawned on a remote node, Parameters
must
implement MeshPayload
.
sourcetype State: MeshPayload
type State: MeshPayload
State used to implement hot restart. Used with Worker::restart
.
Required Associated Constants§
sourceconst ID: WorkerId<Self::Parameters>
const ID: WorkerId<Self::Parameters>
String identifying the Worker. Used when launching workers in separate processes to specify which workers are supported and which worker to launch. IDs must be unique within a given worker host.
Required Methods§
sourcefn new(parameters: Self::Parameters) -> Result<Self>
fn new(parameters: Self::Parameters) -> Result<Self>
Instantiates the worker.
The worker should not start running yet, but it can allocate any resources necessary to run.
Object Safety§
This trait is not object safe.