Struct background_jobs::WorkerConfig[][src]

pub struct WorkerConfig<State> where
    State: Clone + 'static, 
{ /* fields omitted */ }

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]

pub fn new(
    state_fn: impl Send + Sync + Fn() -> State + 'static
) -> WorkerConfig<State>
[src]

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]

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]

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]

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T> From<T> for T[src]

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T> ToOwned for T where
    T: Clone
[src]

type Owned = T

The resulting type after obtaining ownership.

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.