[][src]Struct dbq::WorkerPool

pub struct WorkerPool<H> { /* fields omitted */ }

A group of workers that process jobs from a Queue

Examples

use dbq::*;

#[derive(Clone)]
struct NoopHandler {}

impl Handler for NoopHandler {
    type Error = std::io::Error;

    fn handle(&self, context: JobContext) -> std::result::Result<(), Self::Error> {
        Ok(())
    }
}

let queue = Queue::new(SchemaConfig::default(), "de_lancie_q".to_string());
let conn_params = "postgres://user@localhost";
let mut config = WorkerPoolConfig::new(queue, conn_params, NoopHandler {}).unwrap();
// By default the `WorkerPool` is configured to have as many workers as
// logical cores on the machine, but it can be configured to be any number
config.set_num_workers(2);

let pool = WorkerPool::start(config);
pool.join();

Methods

impl<H: Handler + Send + Clone + 'static> WorkerPool<H>[src]

pub fn start(config: WorkerPoolConfig<H>) -> WorkerPool<H>[src]

Create a new WorkerPool and start the workers in the pool

pub fn config(&self) -> &WorkerPoolConfig<H>[src]

Access the WorkerPoolConfig for this WorkerPool

pub fn join(self)[src]

Shut down the pool waiting for all currently running jobs to finish. This function may block for as long as a job takes to run to completion.

Auto Trait Implementations

impl<H> Send for WorkerPool<H> where
    H: Send

impl<H> Sync for WorkerPool<H> where
    H: Sync

Blanket Implementations

impl<T> From for T[src]

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

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

type Error = Infallible

The type returned in the event of a conversion error.

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

impl<T> Any for T where
    T: 'static + ?Sized
[src]

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

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

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

The type returned in the event of a conversion error.

impl<T> Same for T

type Output = T

Should always be Self