Struct disque::AddJobBuilder
source · pub struct AddJobBuilder<'a> { /* private fields */ }
Expand description
Helper to add a new job
Examples
let disque = Disque::open("redis://127.0.0.1:7711/").unwrap();
let jobid = AddJobBuilder::new(b"example queue", b"my job", 10000
).delay(1440).run(&disque).unwrap();
Implementations§
source§impl<'a> AddJobBuilder<'a>
impl<'a> AddJobBuilder<'a>
sourcepub fn new(
queue_name: &'a [u8],
job: &'a [u8],
timeout_ms: u64
) -> AddJobBuilder<'a>
pub fn new( queue_name: &'a [u8], job: &'a [u8], timeout_ms: u64 ) -> AddJobBuilder<'a>
Creates a new builder for queue_name
.
Timeout is specified in milliseconds.
sourcepub fn queue_name(&mut self, queue_name: &'a [u8]) -> &mut Self
pub fn queue_name(&mut self, queue_name: &'a [u8]) -> &mut Self
Changes the queue name where the job will be added.
sourcepub fn timeout(&mut self, timeout_ms: u64) -> &mut Self
pub fn timeout(&mut self, timeout_ms: u64) -> &mut Self
Changes the timeout. It must be specified in milliseconds.
sourcepub fn replicate(&mut self, replicate: usize) -> &mut Self
pub fn replicate(&mut self, replicate: usize) -> &mut Self
The number of nodes the job should be replicated to.
sourcepub fn delay(&mut self, delay: u64) -> &mut Self
pub fn delay(&mut self, delay: u64) -> &mut Self
The number of seconds that should elapse before the job is queued.
sourcepub fn retry(&mut self, retry: u64) -> &mut Self
pub fn retry(&mut self, retry: u64) -> &mut Self
Period after which, if no ACK is received, the job is put again into the queue for delivery
sourcepub fn ttl(&mut self, ttl: u64) -> &mut Self
pub fn ttl(&mut self, ttl: u64) -> &mut Self
The max job life in seconds. After this time, the job is deleted even if it was not successfully delivered.
sourcepub fn maxlen(&mut self, maxlen: usize) -> &mut Self
pub fn maxlen(&mut self, maxlen: usize) -> &mut Self
If there are already count messages queued for the specified queue name, the message is refused and an error reported to the client.
sourcepub fn async(&mut self, async: bool) -> &mut Self
pub fn async(&mut self, async: bool) -> &mut Self
If true, asks the server to let the command return ASAP and replicate the job to other nodes in the background. Otherwise, the job is put into the queue only when the client gets a positive reply.
sourcepub fn run(&self, disque: &Disque) -> RedisResult<String>
pub fn run(&self, disque: &Disque) -> RedisResult<String>
Executes the addjob command.