[−][src]Struct background_jobs::WorkerConfig
Worker Configuration
This type is used for configuring and creating workers to process jobs. Before starting the
workers, register Processor
types with this struct. This worker registration allows for
different worker processes to handle different sets of workers.
Methods
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<P, J>(self, processor: P) -> WorkerConfig<State> where
J: Job<State = State>,
P: Processor<Job = J> + Send + Sync + 'static,
<<J as Job>::Future as IntoFuture>::Future: Send,
[src]
J: Job<State = State>,
P: Processor<Job = J> + Send + Sync + 'static,
<<J as Job>::Future as IntoFuture>::Future: Send,
Register a Processor
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_processor_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
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,
fn clone(&self) -> WorkerConfig<State>
[src]
fn clone_from(&mut self, source: &Self)
1.0.0[src]
Auto Trait Implementations
impl<State> Send for WorkerConfig<State>
impl<State> Unpin for WorkerConfig<State>
impl<State> Sync for WorkerConfig<State>
impl<State> !UnwindSafe for WorkerConfig<State>
impl<State> !RefUnwindSafe for WorkerConfig<State>
Blanket Implementations
impl<T> ToOwned for T where
T: Clone,
[src]
T: Clone,
type Owned = T
The resulting type after obtaining ownership.
fn to_owned(&self) -> T
[src]
fn clone_into(&self, target: &mut T)
[src]
impl<T, U> Into<U> for T where
U: From<T>,
[src]
U: From<T>,
impl<T> From<T> for 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.
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>,
type Error = <U as TryFrom<T>>::Error
The type returned in the event of a conversion error.
fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>
[src]
impl<T> BorrowMut<T> for T where
T: ?Sized,
[src]
T: ?Sized,
fn borrow_mut(&mut self) -> &mut T
[src]
impl<T> Borrow<T> for T where
T: ?Sized,
[src]
T: ?Sized,
impl<T> Any for T where
T: 'static + ?Sized,
[src]
T: 'static + ?Sized,
impl<T> Erased for T
impl<V, T> VZip<V> for T where
V: MultiLane<T>,
V: MultiLane<T>,