#redis #queue

fourche

A simple task queue named after a lion with forked tail (queue fourché), works with Redis

3 unstable releases

0.2.0 May 22, 2021
0.1.1 Sep 5, 2019
0.1.0 Sep 5, 2019

#560 in Asynchronous

25 downloads per month

Apache-2.0

7KB

Fourché

A simple task queue named after a lion with forked tail (queue fourché), works with Redis.

Example

#[derive(Debug, Deserialize, Serialize)]
struct Job {id: u64 }
// enqueue
let client = redis::Client::open("redis://127.0.0.1:6379/0").unwrap();
let mut conn = client.get_connection().unwrap();

let job = Job { id: 1 }

let mut queue = Queue::new("name", &mut conn);
if let Err(err) = queue.enqueue::<Job>(job) {
    println!("err: {}", err);
}
// dequeue
let client = redis::Client::open("redis://127.0.0.1:6379/0").unwrap();
let mut conn = client.get_connection().unwrap();

let mut queue = Queue::new("name", &mut conn);
loop {
  match queue.dequeue::<Job>() {
    Ok(job) => println!("job: {}", job),
    Err(err) => {
        println!("err: {}", err);
        break;
    },
  }
}

Dependencies

~4.5MB
~112K SLoC