disqrust 0.1.0

A high-level library to implement Disque workers

Crate disqrust [] [src]

A high-level library to implement Disque workers.

extern crate disque;
extern crate disqrust;

use disque::Disque;
use disqrust::{EventLoop, Handler, JobStatus};

#[derive(Clone)]
struct MyHandler(u8);

impl Handler for MyHandler {
    fn process_job(&self, queue_name: &[u8], jobid: &String, body: Vec<u8>) -> JobStatus {
        match queue_name {
            b"send email" => { /* send email */; JobStatus::AckJob },
            _ => JobStatus::NAck,
        }
    }
}

fn main() {
    let disque = Disque::open("redis://127.0.0.1:7711/").unwrap();
    let mut el = EventLoop::new(disque, 4, MyHandler(0));
    el.watch_queue(b"my queue".to_vec());
    el.run(1000);
}

Structs

EventLoop

Workers manager.

Enums

JobStatus

Once a job execution finishes, change its status by performing one of this actions.

Traits

Handler

Handles a job task.