Expand description
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)?;
let result = queue.result(uuid)?.unwrap();
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(process, None, Some(60), None, Some(30), Some(false), None)?;
Structs§
- Queue
- Queue
Enums§
- Status
- Job status