Crate oppgave [] [src]

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

Queue

A Queue allows to push new tasks or wait for them

TaskGuard

A wrapper of the fetched task

Traits

TaskDecodable

Task objects that can be reconstructed from the JSON stored in Redis

TaskEncodable

Task objects that can be encoded to JSON to be stored in Redis