Expand description
oppgave - A simple Redis-based task queue
§Example: Producer
ⓘ
#[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 });§Example: Worker
ⓘ
#[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 worker = Queue::new("default".into(), con);
while let Some(task) = worker.next() {
println!("Working with Job {}", job.id);
}Structs§
Traits§
- Task
Decodable - Task objects that can be reconstructed from the JSON stored in Redis
- Task
Encodable - Task objects that can be encoded to JSON to be stored in Redis