Struct background_jobs::WorkerConfig
source · [−]pub struct WorkerConfig<State, M> where
State: 'static + Clone, { /* private fields */ }
Expand description
Worker Configuration
This type is used for configuring and creating workers to process jobs. Before starting the
workers, register Job
types with this struct. This worker registration allows for
different worker processes to handle different sets of workers.
Implementations
pub fn new_managed<S>(
storage: S,
state_fn: impl Fn(QueueHandle) -> State + Send + Sync + 'static
) -> WorkerConfig<State, Managed> where
S: 'static + Storage + Send + Sync,
pub fn new_managed<S>(
storage: S,
state_fn: impl Fn(QueueHandle) -> State + Send + Sync + 'static
) -> WorkerConfig<State, Managed> where
S: 'static + Storage + Send + Sync,
Create a new managed WorkerConfig
The supplied function should return the State required by the jobs intended to be processed. The function must be sharable between threads, but the state itself does not have this requirement.
Create a new WorkerConfig in the current arbiter
The supplied function should return the State required by the jobs intended to be processed. The function must be sharable between threads, but the state itself does not have this requirement.
pub fn new_in_arbiter<S>(
arbiter: ArbiterHandle,
storage: S,
state_fn: impl Fn(QueueHandle) -> State + Send + Sync + 'static
) -> WorkerConfig<State, Unmanaged> where
S: 'static + Storage + Send + Sync,
pub fn new_in_arbiter<S>(
arbiter: ArbiterHandle,
storage: S,
state_fn: impl Fn(QueueHandle) -> State + Send + Sync + 'static
) -> WorkerConfig<State, Unmanaged> where
S: 'static + Storage + Send + Sync,
Create a new WorkerConfig in the provided arbiter
The supplied function should return the State required by the jobs intended to be processed. The function must be sharable between threads, but the state itself does not have this requirement.
Start the workers in the provided arbiter
Register a Job
with the worker
This enables the worker to handle jobs associated with this processor. If a processor is not registered, none of it’s jobs will be run, even if another processor handling the same job queue is registered.
Set the number of workers to run for a given queue
This does not spin up any additional threads. The Arbiter
the workers are spawned onto
will handle processing all workers, regardless of how many are configured.
By default, 4 workers are spawned
Trait Implementations
Auto Trait Implementations
impl<State, M> !RefUnwindSafe for WorkerConfig<State, M>
impl<State, M> Send for WorkerConfig<State, M> where
M: Send,
impl<State, M> Sync for WorkerConfig<State, M> where
M: Sync,
impl<State, M> Unpin for WorkerConfig<State, M> where
M: Unpin,
impl<State, M> !UnwindSafe for WorkerConfig<State, M>
Blanket Implementations
Mutably borrows from an owned value. Read more
Instruments this type with the provided Span
, returning an
Instrumented
wrapper. Read more
Attaches the provided Subscriber
to this type, returning a
WithDispatch
wrapper. Read more
Attaches the current default Subscriber
to this type, returning a
WithDispatch
wrapper. Read more
Attaches the provided Subscriber
to this type, returning a
WithDispatch
wrapper. Read more
Attaches the current default Subscriber
to this type, returning a
WithDispatch
wrapper. Read more