Struct disque::Disque

source ·
pub struct Disque { /* private fields */ }

Implementations§

source§

impl Disque

source

pub fn open<T: IntoConnectionInfo>(params: T) -> RedisResult<Disque>

Opens a new connection to a Disque server.

Examples
let disque = Disque::open("redis://127.0.0.1:7711/").unwrap();
source

pub fn hello( &self ) -> RedisResult<(u8, String, Vec<(String, String, u16, u32)>)>

The hello command returns information about the disque cluster.

Examples
let disque = Disque::open("redis://127.0.0.1:7711/").unwrap();
let (_, nodeid, _) = disque.hello().unwrap();
println!("Connected to node {}", nodeid);
source

pub fn addjob( &self, queue_name: &[u8], job: &[u8], timeout: Duration, replicate: Option<usize>, delay: Option<Duration>, retry: Option<Duration>, ttl: Option<Duration>, maxlen: Option<usize>, async: bool ) -> RedisResult<String>

Adds a job to a queue.

Examples
let disque = Disque::open("redis://127.0.0.1:7711/").unwrap();
let jobid = disque.addjob(b"my queue", b"my job",
  Duration::from_secs(10), None, None, None, None, None, false
  ).unwrap();
println!("My job id is {}", jobid);
source

pub fn getjob_count( &self, nohang: bool, timeout: Option<Duration>, count: usize, queues: &[&[u8]] ) -> RedisResult<Vec<(Vec<u8>, String, Vec<u8>)>>

Gets up to count jobs from certain queues.

Examples
let disque = Disque::open("redis://127.0.0.1:7711/").unwrap();
let queue = b"my getjob_count queue";
disque.addjob(queue, b"my job 1", Duration::from_secs(10),
  None, None, None, None, None, false
  ).unwrap();
disque.addjob(queue, b"my job 2", Duration::from_secs(10),
  None, None, None, None, None, false
  ).unwrap();

let jobs = disque.getjob_count(true, None, 10, &[queue]).unwrap();
assert_eq!(jobs.len(), 2);
assert_eq!(jobs[0].2, b"my job 1");
assert_eq!(jobs[1].2, b"my job 2");
source

pub fn getjob_count_withcounters( &self, nohang: bool, timeout: Option<Duration>, count: usize, queues: &[&[u8]] ) -> RedisResult<Vec<(Vec<u8>, String, Vec<u8>, u32, u32)>>

source

pub fn getjob( &self, nohang: bool, timeout: Option<Duration>, queues: &[&[u8]] ) -> RedisResult<Option<(Vec<u8>, String, Vec<u8>)>>

Gets a single job from any of the specified queues.

source

pub fn getjob_withcounters( &self, nohang: bool, timeout: Option<Duration>, queues: &[&[u8]] ) -> RedisResult<Option<(Vec<u8>, String, Vec<u8>, u32, u32)>>

Gets a single job from any of the specified queues with its nack and additional deliveries count.

source

pub fn ackjobs(&self, jobids: &[&[u8]]) -> RedisResult<usize>

Acknowledge jobs.

source

pub fn ackjob(&self, jobid: &[u8]) -> RedisResult<bool>

Acknowledge a job.

source

pub fn fastackjobs(&self, jobids: &[&[u8]]) -> RedisResult<usize>

Fast acknowledge jobs.

source

pub fn fastackjob(&self, jobid: &[u8]) -> RedisResult<bool>

Fast acknowledge a job.

source

pub fn working(&self, jobid: &[u8]) -> RedisResult<Duration>

Tell Disque that a job is still processed.

source

pub fn nackjobs(&self, jobids: &[&[u8]]) -> RedisResult<usize>

Tells Disque to put back the jobs in the queue ASAP. Should be used when the worker was not able to process a message and wants the message to be put back into the queue in order to be processed again.

source

pub fn nackjob(&self, jobid: &[u8]) -> RedisResult<bool>

Tells Disque to put back a job in the queue ASAP.

source

pub fn info(&self) -> RedisResult<InfoDict>

Information about the server

source

pub fn qlen(&self, queue_name: &[u8]) -> RedisResult<usize>

Size of the queue

source

pub fn qpeek( &self, queue_name: &[u8], count: i64 ) -> RedisResult<Vec<Vec<Vec<u8>>>>

Gets jobs from queue_name up to the absolute number of count. If count is negative, it will be from newest to oldest.

source

pub fn enqueue(&self, jobids: &[&[u8]]) -> RedisResult<usize>

Add jobs to queues

source

pub fn dequeue(&self, jobids: &[&[u8]]) -> RedisResult<usize>

Remove jobs from queue

source

pub fn deljobs(&self, jobids: &[&[u8]]) -> RedisResult<usize>

Completely delete jobs from a single node.

source

pub fn deljob(&self, jobid: &[u8]) -> RedisResult<bool>

Completely delete a job from a single node.

source

pub fn show(&self, jobid: &[u8]) -> RedisResult<Option<HashMap<String, Value>>>

Returns full information about a job, like its current state and data.

source

pub fn qscan( &self, cursor: u64, count: u64, busyloop: bool, minlen: Option<u64>, maxlen: Option<u64>, importrate: Option<u64> ) -> RedisResult<Iter<'_, Vec<u8>>>

Iterator to run all queues that fulfil a criteria. The iterator will batch into segments of approximate count size.

source

pub fn jscan_id( &self, cursor: u64, count: u64, busyloop: bool, queue: Option<&[u8]>, states: &[&str] ) -> RedisResult<Iter<'_, String>>

Iterator for all job ids that fulfil a criteria. The iterator will batch into segments of approximate count size.

source

pub fn jscan_all( &self, cursor: u64, count: u64, busyloop: bool, queue: Option<&[u8]>, states: &[&str] ) -> RedisResult<Iter<'_, HashMap<String, Value>>>

Iterator for all jobs that fulfil a criteria. The iterator will batch into segments of approximate count size.

source

pub fn qstat(&self, queue_name: &[u8]) -> RedisResult<HashMap<String, Value>>

Auto Trait Implementations§

§

impl !RefUnwindSafe for Disque

§

impl Send for Disque

§

impl !Sync for Disque

§

impl Unpin for Disque

§

impl UnwindSafe for Disque

Blanket Implementations§

source§

impl<T> Any for Twhere T: 'static + ?Sized,

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

impl<T> Borrow<T> for Twhere T: ?Sized,

const: unstable · source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for Twhere T: ?Sized,

const: unstable · source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
source§

impl<T> From<T> for T

const: unstable · source§

fn from(t: T) -> T

Returns the argument unchanged.

source§

impl<T, U> Into<U> for Twhere U: From<T>,

const: unstable · source§

fn into(self) -> U

Calls U::from(self).

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

source§

impl<T, U> TryFrom<U> for Twhere U: Into<T>,

§

type Error = Infallible

The type returned in the event of a conversion error.
const: unstable · source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
source§

impl<T, U> TryInto<U> for Twhere U: TryFrom<T>,

§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
const: unstable · source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.