Crate rjq [] [src]

Redis job queue and worker crate.

Enqueue jobs

extern crate rjq;

use std::time::Duration;
use std::thread::sleep;
use rjq::{Queue, Status};

let queue = Queue::new("redis://localhost/", "rjq");
let mut uuids = Vec::new();

for _ in 0..10 {
    sleep(Duration::from_millis(100));
    uuids.push(queue.enqueue(vec![], 30)?);
}

sleep(Duration::from_millis(10000));

for uuid in uuids.iter() {
    let status = queue.status(uuid).unwrap_or(Status::FAILED);
    let result = queue.result(uuid).unwrap_or("".to_string());
    println!("{} {:?} {}", uuid, status, result);
}

Work on jobs

extern crate rjq;

use std::time::Duration;
use std::thread::sleep;
use std::error::Error;
use rjq::Queue;

fn process(uuid: String, _: Vec<String>) -> Result<String, Box<Error>> {
    sleep(Duration::from_millis(1000));
    println!("{}", uuid);
    Ok(format!("hi from {}", uuid))
}

let queue = Queue::new("redis://localhost/", "rjq");
queue.work(1, process, 5, 10, 30, false, true)?;

Structs

Queue

Queue

Enums

Status

Job status