Crates.io | sidekiq |
lib.rs | sidekiq |
version | 0.12.0 |
source | src |
created_at | 2016-05-22 21:57:57.048747 |
updated_at | 2022-09-23 06:34:33.98447 |
description | Rust Sidekiq Client |
homepage | https://github.com/spk/rust-sidekiq |
repository | https://github.com/spk/rust-sidekiq.git |
max_upload_size | |
id | 5147 |
size | 27,542 |
Sidekiq client allowing to push jobs. Using the Sidekiq job format as reference.
[dependencies]
sidekiq = "0.12"
use sidekiq::{Job, Value};
use sidekiq::{Client, ClientOpts, create_redis_pool};
use time::{OffsetDateTime, Duration};
let ns = "test";
let client_opts = ClientOpts {
namespace: Some(ns.to_string()),
..Default::default()
};
let pool = create_redis_pool().unwrap();
let client = Client::new(pool, client_opts);
let class = "MyClass".to_string();
// basic job
let job = Job::new(class, vec![sidekiq::Value::Null], Default::default());
match client.push(job) {
Ok(_) => {},
Err(err) => {
println!("Sidekiq push failed: {}", err);
},
}
// scheduled-jobs (perform_in)
let job = Job::new(class, vec![sidekiq::Value::Null], Default::default());
let interval = Duration::hours(1);
match client.perform_in(interval, job) {
Ok(_) => {},
Err(err) => {
println!("Sidekiq push failed: {}", err);
},
}
// scheduled-jobs (perform_at)
let job = Job::new(class, vec![sidekiq::Value::Null], Default::default());
let start_at = OffsetDateTime::now_utc().checked_add(Duration::HOUR).unwrap();
match client.perform_at(start_at, job) {
Ok(_) => {},
Err(err) => {
println!("Sidekiq push failed: {}", err);
},
}
The MIT License
Copyright (c) 2016-2021 Laurent Arnoud laurent@spkdev.net