[−][src]Struct dbq::WorkerPool
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,
H: Send,
impl<H> Sync for WorkerPool<H> where
H: Sync,
H: Sync,
Blanket Implementations
impl<T> From for T
[src]
impl<T, U> Into for T where
U: From<T>,
[src]
U: From<T>,
impl<T, U> TryFrom 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> Borrow for T where
T: ?Sized,
[src]
T: ?Sized,
impl<T> Any for T where
T: 'static + ?Sized,
[src]
T: 'static + ?Sized,
impl<T> BorrowMut for T where
T: ?Sized,
[src]
T: ?Sized,
fn borrow_mut(&mut self) -> &mut T
[src]
impl<T, U> TryInto 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> Same for T
type Output = T
Should always be Self