Struct oppgave::Queue
[−]
[src]
pub struct Queue { /* fields omitted */ }
A Queue allows to push new tasks or wait for them
Allows for reliable job processing.
On fetch jobs are moved to a backup queue. They are popped from the backup queue, when the returned task guard is dropped.
Example
#[derive(RustcDecodable, RustcEncodable)] struct Job { id: u64 } let client = redis::Client::open("redis://127.0.0.1/").unwrap(); let con = client.get_connection().unwrap(); let producer = Queue::new("default".into(), con); producer.push(Job{ id: 42 });
Methods
impl Queue
[src]
fn new(name: String, client: Connection) -> Queue
Create a new Queue for the given name
fn stop(&self)
Stop processing the queue
On the next .next()
call None
will be returned.
fn is_stopped(&self) -> bool
Check if queue processing is stopped
fn queue(&self) -> &str
Get the full queue name
fn backup_queue(&self) -> &str
Get the full backup queue name
fn size(&self) -> u64
Get the number of remaining tasks in the queue
fn push<T: TaskEncodable>(&self, task: T)
Push a new task to the queue
fn next<T: TaskDecodable>(&self) -> Option<RedisResult<TaskGuard<T>>>
Grab the next task from the queue
This method blocks and waits until a new task is available.