Crates.io | fourche |
lib.rs | fourche |
version | 0.2.0 |
source | src |
created_at | 2019-09-05 15:28:55.459686 |
updated_at | 2021-05-22 19:38:03.733262 |
description | A simple task queue named after a lion with forked tail (queue fourché), works with Redis. |
homepage | https://gitlab.com/grauwoelfchen/fourche |
repository | https://gitlab.com/grauwoelfchen/fourche |
max_upload_size | |
id | 162448 |
size | 16,487 |
A simple task queue named after a lion with forked tail (queue fourché), works with Redis.
#[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;
},
}
}