Struct background_jobs::WorkerConfig [−][src]
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
impl<State> WorkerConfig<State> where
State: Clone + 'static,
[src]
State: Clone + 'static,
pub fn new(
state_fn: impl Send + Sync + Fn() -> State + 'static
) -> WorkerConfig<State>
[src]
state_fn: impl Send + Sync + Fn() -> State + 'static
) -> WorkerConfig<State>
Create a new 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.
pub fn register<J>(self) -> WorkerConfig<State> where
J: Job<State = State>,
[src]
J: Job<State = State>,
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.
pub fn set_worker_count(self, queue: &str, count: u64) -> WorkerConfig<State>
[src]
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
pub fn start(self, queue_handle: QueueHandle)
[src]
Start the workers in the current arbiter
This method will panic if not called from an actix runtime
pub fn start_in_arbiter(self, arbiter: &Arbiter, queue_handle: QueueHandle)
[src]
Start the workers in the provided arbiter
Trait Implementations
impl<State> Clone for WorkerConfig<State> where
State: Clone + 'static,
[src]
State: Clone + 'static,
pub fn clone(&self) -> WorkerConfig<State>
[src]
pub fn clone_from(&mut self, source: &Self)
1.0.0[src]
Auto Trait Implementations
impl<State> !RefUnwindSafe for WorkerConfig<State>
[src]
impl<State> Send for WorkerConfig<State>
[src]
impl<State> Sync for WorkerConfig<State>
[src]
impl<State> Unpin for WorkerConfig<State>
[src]
impl<State> !UnwindSafe for WorkerConfig<State>
[src]
Blanket Implementations
impl<T> Any for T where
T: 'static + ?Sized,
[src]
T: 'static + ?Sized,
impl<T> Borrow<T> for T where
T: ?Sized,
[src]
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
[src]
T: ?Sized,
pub fn borrow_mut(&mut self) -> &mut T
[src]
impl<T> From<T> for T
[src]
impl<T, U> Into<U> for T where
U: From<T>,
[src]
U: From<T>,
impl<T> ToOwned for T where
T: Clone,
[src]
T: Clone,
type Owned = T
The resulting type after obtaining ownership.
pub fn to_owned(&self) -> T
[src]
pub fn clone_into(&self, target: &mut T)
[src]
impl<T, U> TryFrom<U> for T where
U: Into<T>,
[src]
U: Into<T>,
type Error = Infallible
The type returned in the event of a conversion error.
pub fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
[src]
impl<T, U> TryInto<U> for T where
U: TryFrom<T>,
[src]
U: TryFrom<T>,