pub struct Client {
    pub redis_pool: ConnectionManager,
    pub namespace: Option<String>,
}

Fields

redis_pool: ConnectionManagernamespace: Option<String>

Implementations

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);
    },
}

Auto Trait Implementations

Blanket Implementations

Gets the TypeId of self. Read more
Immutably borrows from an owned value. Read more
Mutably borrows from an owned value. Read more

Returns the argument unchanged.

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Instruments this type with the current Span, returning an Instrumented wrapper. Read more

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

The type returned in the event of a conversion error.
Performs the conversion.
The type returned in the event of a conversion error.
Performs the conversion.
Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more