pub struct Client {
pub redis_pool: ConnectionManager,
pub namespace: Option<String>,
}
Fields
redis_pool: ConnectionManager
namespace: Option<String>
Implementations
sourceimpl Client
impl Client
Examples
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 = "Maman";
let job = Job::new(class.to_string(), vec![sidekiq::Value::Null], Default::default());
match client.push(job) {
Ok(_) => {},
Err(err) => {
println!("Sidekiq push failed: {}", err);
},
}
let job = Job::new(class.to_string(), 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);
},
}
let job = Job::new(class.to_string(), 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);
},
}
pub fn new(redis_pool: ConnectionManager, opts: ClientOpts) -> Client
pub fn perform_in(&self, interval: Duration, job: Job) -> Result<(), ClientError>
pub fn perform_at(
&self,
datetime: OffsetDateTime,
job: Job
) -> Result<(), ClientError>
pub fn push(&self, job: Job) -> Result<(), ClientError>
pub fn push_bulk(&self, jobs: &[Job]) -> Result<(), ClientError>
pub async fn perform_in_async(
&self,
interval: Duration,
job: Job
) -> Result<(), ClientError>
pub async fn perform_at_async(
&self,
datetime: OffsetDateTime,
job: Job
) -> Result<(), ClientError>
pub async fn push_async(&self, job: Job) -> Result<(), ClientError>
pub async fn push_bulk_async(&self, jobs: &[Job]) -> Result<(), ClientError>
Auto Trait Implementations
impl !RefUnwindSafe for Client
impl Send for Client
impl Sync for Client
impl Unpin for Client
impl !UnwindSafe for Client
Blanket Implementations
sourceimpl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
const: unstable · sourcefn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more