Struct rjq::Queue
[−]
[src]
pub struct Queue { /* fields omitted */ }
Queue
Methods
impl Queue
[src]
fn new(url: &str, name: &str) -> Queue
Init new queue object
url
- redis url to connect
name
- queue name
fn drop(&self) -> Result<(), Box<Error>>
Delete enqueued jobs
fn enqueue(&self,
args: Vec<String>,
expire: usize)
-> Result<String, Box<Error>>
args: Vec<String>,
expire: usize)
-> Result<String, Box<Error>>
Enqueue new job
args
- job arguments
expire
- job expiration time in seconds, if hasn't started during this time it will be
removed
Returns unique job identifier
fn status(&self, uuid: &str) -> Result<Status, Box<Error>>
Get job status
uuid
- unique job identifier
Returns job status
fn work<F: Fn(String, Vec<String>) -> Result<String, Box<Error>> + Send + Sync + 'static>(&self,
wait: usize,
fun: F,
timeout: usize,
freq: usize,
expire: usize,
fall: bool,
infinite: bool)
-> Result<(), Box<Error>>
wait: usize,
fun: F,
timeout: usize,
freq: usize,
expire: usize,
fall: bool,
infinite: bool)
-> Result<(), Box<Error>>
Work on queue, process enqueued jobs
wait
- time to wait in single iteration to pop next job, set 1-10 if not sure about that
fun
- function that would work on jobs
timeout
- timeout in seconds, if job hasn't been completed during this time, it will be
marked as lost
freq
- frequency of checking job status while counting on timeout, number of checks per
second, recommended values from 1 to 50, if not sure set to 10
expire
- job result expiration time in seconds
fall
- if set to true then worker will panic if job was lost
infinite
- if set to false then worker will process one job and quit
fn result(&self, uuid: &str) -> Result<String, Box<Error>>
Get job result
uuid
- unique job identifier
Returns job result