[][src]Struct dbq::Queue

pub struct Queue { /* fields omitted */ }

Represents a job queue stored in the database. Because the queue is stored in the database, the queue should be considered to have internal mutability

Examples

use dbq::{Queue, SchemaConfig};
use postgres::{Connection, TlsMode};
use serde_json::value::Value;

let q = Queue::new(SchemaConfig::default(), "de_lancie_q".to_string());

let conn = Connection::connect("postgres://user@localhost".to_string(), TlsMode::None)
    .unwrap();
q.enqueue("send_email", Value::String("example@example.com".to_string()), 3, &conn);
q.enqueue("send_sms", Value::String("+1-555-555-5555".to_string()), 3, &conn);

Methods

impl Queue[src]

pub fn new(schema_config: SchemaConfig, name: String) -> Queue[src]

pub fn enqueue<A: Serialize, C: GenericConnection>(
    &self,
    class: &str,
    args: A,
    max_attempts: u32,
    conn: &C
) -> Result<u64>
[src]

Add a new job to the queue

pub fn len<C: GenericConnection>(&self, conn: &C) -> Result<usize>[src]

Length of the queue

pub fn lookup_in_queue<C: GenericConnection>(
    &self,
    job_id: u64,
    conn: &C
) -> Result<Option<Job>>
[src]

Find a job in the queue by its job ID

pub fn lookup_in_dead_letters<C: GenericConnection>(
    &self,
    job_id: u64,
    conn: &C
) -> Result<Option<Job>>
[src]

Find a job in the queue's "dead letter" storage by its job ID

pub fn clear<C: GenericConnection>(&self, conn: &C) -> Result<()>[src]

Delete all jobs from the queue. Calling this function may block until all running jobs in the queue finish

Trait Implementations

impl Clone for Queue[src]

default fn clone_from(&mut self, source: &Self)
1.0.0
[src]

Performs copy-assignment from source. Read more

impl Debug for Queue[src]

Auto Trait Implementations

impl Send for Queue

impl Sync for Queue

Blanket Implementations

impl<T> From for T[src]

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

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

type Owned = T

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