Struct ocypod::application::RedisJob
source · Expand description
Convenient wrapper struct for combing a job ID plus a connection.
Fields
id: u64
key: String
Implementations
sourceimpl<'a> RedisJob<'a>
impl<'a> RedisJob<'a>
sourcepub fn new(id: u64, conn: &'a Connection) -> Self
pub fn new(id: u64, conn: &'a Connection) -> Self
Create a new RedisJob with given ID and given connection. This ID may or may not exist.
sourcepub fn metadata(&self, fields: &[Field]) -> OcyResult<JobMeta>
pub fn metadata(&self, fields: &[Field]) -> OcyResult<JobMeta>
Get a populated JobMeta
from given connection by getting data for a given hash key and fields.
sourcepub fn timeout_metadata(&self) -> OcyResult<TimeoutMeta>
pub fn timeout_metadata(&self) -> OcyResult<TimeoutMeta>
Get subset of metadata needed to check whether this job has timed out or not.
sourcepub fn update(&self, update_req: &UpdateRequest) -> OcyResult<()>
pub fn update(&self, update_req: &UpdateRequest) -> OcyResult<()>
Update this job’s status and/or output from a given request.
sourcepub fn complete<'b>(&self, pipe: &'b mut Pipeline) -> &'b mut Pipeline
pub fn complete<'b>(&self, pipe: &'b mut Pipeline) -> &'b mut Pipeline
Add commands to a pipeline to mark this job as completed.
Note: caller is responsible for ensuring job exists and status change is valid before this is called.
sourcepub fn requeue<'b>(
&self,
pipe: &'b mut Pipeline,
incr_retries: bool
) -> OcyResult<&'b mut Pipeline>
pub fn requeue<'b>(
&self,
pipe: &'b mut Pipeline,
incr_retries: bool
) -> OcyResult<&'b mut Pipeline>
Add commands to pipeline to re-queue this job so that it can be retried later.
If incr_retries
is true, then increment the count of retry attempts for this job. This will
typically be done for automatic retries, but not for manually requested retries.
sourcepub fn cancel<'b>(&self, pipe: &'b mut Pipeline) -> OcyResult<&'b mut Pipeline>
pub fn cancel<'b>(&self, pipe: &'b mut Pipeline) -> OcyResult<&'b mut Pipeline>
Add commands to pipeline to re-queue this job so that it can be retried later.
sourcepub fn fail<'b>(
&self,
pipe: &'b mut Pipeline,
status: &Status
) -> &'b mut Pipeline
pub fn fail<'b>(
&self,
pipe: &'b mut Pipeline,
status: &Status
) -> &'b mut Pipeline
Add commands to pipeline to mark this job as failed or timed out.
Note: caller is responsible for ensuring job exists and status change is valid before this is called.
sourcepub fn end_failed(&self) -> OcyResult<bool>
pub fn end_failed(&self) -> OcyResult<bool>
Move this job to the ended queue if it’s failed or timed out.
sourcepub fn fields(&self, fields: Option<&[Field]>) -> OcyResult<JobMeta>
pub fn fields(&self, fields: Option<&[Field]>) -> OcyResult<JobMeta>
Get some or all fields of this job’s metadata.
If None
is given, then all fields are fetched.
sourcepub fn queue(&self) -> OcyResult<RedisQueue<'_>>
pub fn queue(&self) -> OcyResult<RedisQueue<'_>>
Get queue this job was created in. This queue may or may not exist.
sourcepub fn set_output(&self, value: &Value) -> OcyResult<()>
pub fn set_output(&self, value: &Value) -> OcyResult<()>
Update this job’s output field in a transaction.
sourcepub fn set_output_in_pipe<'b>(
&self,
pipe: &'b mut Pipeline,
value: &Value
) -> OcyResult<&'b mut Pipeline>
pub fn set_output_in_pipe<'b>(
&self,
pipe: &'b mut Pipeline,
value: &Value
) -> OcyResult<&'b mut Pipeline>
Add commands to update this job’s output to a pipeline.
sourcepub fn set_status(&self, status: &Status) -> OcyResult<()>
pub fn set_status(&self, status: &Status) -> OcyResult<()>
Update this job’s status field in a transaction.
sourcepub fn set_status_in_pipe<'b>(
&self,
pipe: &'b mut Pipeline,
status: &Status
) -> OcyResult<&'b mut Pipeline>
pub fn set_status_in_pipe<'b>(
&self,
pipe: &'b mut Pipeline,
status: &Status
) -> OcyResult<&'b mut Pipeline>
Add commands to update this job’s status to a pipeline.
Checks the validity of status transitions.
sourcepub fn update_heartbeat(&self) -> OcyResult<()>
pub fn update_heartbeat(&self) -> OcyResult<()>
Updates a job’s last heartbeat date/time.
sourcepub fn apply_expiry(&self) -> OcyResult<bool>
pub fn apply_expiry(&self) -> OcyResult<bool>
Expires a job in a transaction.
Callers should typically check for job expiry outside of a transaction (and probably in a pipeline), then only call this on jobs to expire (since transaction here is much more expensive).
sourcepub fn apply_timeouts(&self) -> OcyResult<bool>
pub fn apply_timeouts(&self) -> OcyResult<bool>
Times out a job in a transaction.
Callers should typically check for job timeout outside of a transaction (and probably in a pipeline), then only call this on jobs to timeout (since transaction here is much more expensive).
sourcepub fn apply_retries(&self) -> OcyResult<bool>
pub fn apply_retries(&self) -> OcyResult<bool>
Retries out a job in a transaction.
Callers should typically check for job retries outside of a transaction (and probably in a pipeline), then only call this on jobs to retry (since transaction here is much more expensive).
sourcepub fn delete(&self) -> OcyResult<bool>
pub fn delete(&self) -> OcyResult<bool>
Deletes this job from the server in a transaction.
Returns
Returns true
if this job was deleted, false
if the job wasn’t found.
sourcepub fn delete_in_pipe<'b>(
&self,
pipe: &'b mut Pipeline
) -> OcyResult<&'b mut Pipeline>
pub fn delete_in_pipe<'b>(
&self,
pipe: &'b mut Pipeline
) -> OcyResult<&'b mut Pipeline>
Add commands to delete this job status to a pipeline.
Trait Implementations
sourceimpl<'a> ToRedisArgs for &'a RedisJob<'a>
impl<'a> ToRedisArgs for &'a RedisJob<'a>
sourcefn to_redis_args(&self) -> Vec<Vec<u8>>ⓘNotable traits for Vec<u8, A>impl<A> Write for Vec<u8, A>where
A: Allocator,
fn to_redis_args(&self) -> Vec<Vec<u8>>ⓘNotable traits for Vec<u8, A>impl<A> Write for Vec<u8, A>where
A: Allocator,
A: Allocator,
sourcefn write_redis_args(&self, out: &mut Vec<Vec<u8>>)
fn write_redis_args(&self, out: &mut Vec<Vec<u8>>)
sourcefn describe_numeric_behavior(&self) -> NumericBehavior
fn describe_numeric_behavior(&self) -> NumericBehavior
INCR
vs INCRBYFLOAT
). Read moresourcefn is_single_arg(&self) -> bool
fn is_single_arg(&self) -> bool
GET
and MGET
variants. Read more