Struct ocypod::application::RedisJob
source · [−]Expand description
Convenient wrapper struct for combing a job ID plus a connection.
Fields
id: u64
ID of the job.
key: String
Redis key used to store the job under. Can be derived from the ID, but stored separately avoid having to regenerate it each time it’s needed.
Implementations
sourceimpl<'a> RedisJob<'a>
impl<'a> RedisJob<'a>
sourcepub fn new(redis_manager: &'a RedisManager, id: u64) -> Self
pub fn new(redis_manager: &'a RedisManager, id: u64) -> Self
Create a new RedisJob with given ID and given connection. This ID may or may not exist.
sourcepub async fn metadata<C>(
&self,
conn: &mut C,
fields: &[Field]
) -> OcyResult<JobMeta> where
C: ConnectionLike,
pub async fn metadata<C>(
&self,
conn: &mut C,
fields: &[Field]
) -> OcyResult<JobMeta> where
C: ConnectionLike,
Get a populated JobMeta
from given connection by getting data for a given hash key and fields.
sourcepub async fn timeout_metadata<C>(&self, conn: &mut C) -> OcyResult<TimeoutMeta> where
C: ConnectionLike + Send,
pub async fn timeout_metadata<C>(&self, conn: &mut C) -> OcyResult<TimeoutMeta> where
C: ConnectionLike + Send,
Get subset of metadata needed to check whether this job has timed out or not.
sourcepub async fn update<C>(
&self,
conn: &mut C,
update_req: &UpdateRequest
) -> OcyResult<()> where
C: ConnectionLike + Send,
pub async fn update<C>(
&self,
conn: &mut C,
update_req: &UpdateRequest
) -> OcyResult<()> where
C: ConnectionLike + Send,
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 async fn requeue<'b, C: ConnectionLike + Send>(
&self,
conn: &mut C,
pipe: &'b mut Pipeline,
incr_retries: bool
) -> OcyResult<&'b mut Pipeline>
pub async fn requeue<'b, C: ConnectionLike + Send>(
&self,
conn: &mut C,
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 async fn cancel<'b, C: ConnectionLike + Send>(
&self,
conn: &mut C,
pipe: &'b mut Pipeline
) -> OcyResult<&'b mut Pipeline>
pub async fn cancel<'b, C: ConnectionLike + Send>(
&self,
conn: &mut C,
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 async fn end_failed<C: ConnectionLike + Send>(
&self,
conn: &mut C
) -> OcyResult<bool>
pub async fn end_failed<C: ConnectionLike + Send>(
&self,
conn: &mut C
) -> OcyResult<bool>
Move this job to the ended queue if it’s failed or timed out.
sourcepub async fn fields<C: ConnectionLike>(
&self,
conn: &mut C,
fields: Option<&[Field]>
) -> OcyResult<JobMeta>
pub async fn fields<C: ConnectionLike>(
&self,
conn: &mut C,
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 async fn queue<C: ConnectionLike + Send>(
&self,
conn: &mut C
) -> OcyResult<RedisQueue<'a>>
pub async fn queue<C: ConnectionLike + Send>(
&self,
conn: &mut C
) -> OcyResult<RedisQueue<'a>>
Get queue this job was created in. This queue may or may not exist.
sourcepub async fn output<C: ConnectionLike + Send>(
&self,
conn: &mut C
) -> OcyResult<Value>
pub async fn output<C: ConnectionLike + Send>(
&self,
conn: &mut C
) -> OcyResult<Value>
Get this job’s output field.
sourcepub async fn set_output<C: ConnectionLike + Send>(
&self,
conn: &mut C,
value: &Value
) -> OcyResult<()>
pub async fn set_output<C: ConnectionLike + Send>(
&self,
conn: &mut C,
value: &Value
) -> OcyResult<()>
Update this job’s output field in a transaction.
sourcepub async fn set_output_in_pipe<'b, C: ConnectionLike + Send>(
&self,
conn: &mut C,
pipe: &'b mut Pipeline,
value: &Value
) -> OcyResult<&'b mut Pipeline>
pub async fn set_output_in_pipe<'b, C: ConnectionLike + Send>(
&self,
conn: &mut C,
pipe: &'b mut Pipeline,
value: &Value
) -> OcyResult<&'b mut Pipeline>
Add commands to update this job’s output to a pipeline.
sourcepub async fn status<C: ConnectionLike + Send>(
&self,
conn: &mut C
) -> OcyResult<Status>
pub async fn status<C: ConnectionLike + Send>(
&self,
conn: &mut C
) -> OcyResult<Status>
Get this job’s status field.
sourcepub async fn set_status<C: ConnectionLike + Send>(
&self,
conn: &mut C,
status: &Status
) -> OcyResult<()>
pub async fn set_status<C: ConnectionLike + Send>(
&self,
conn: &mut C,
status: &Status
) -> OcyResult<()>
Update this job’s status field in a transaction.
sourcepub async fn set_status_in_pipe<'b, C: ConnectionLike + Send>(
&self,
conn: &mut C,
pipe: &'b mut Pipeline,
status: &Status
) -> OcyResult<&'b mut Pipeline>
pub async fn set_status_in_pipe<'b, C: ConnectionLike + Send>(
&self,
conn: &mut C,
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 async fn update_heartbeat<C: ConnectionLike + Send>(
&self,
conn: &mut C
) -> OcyResult<()>
pub async fn update_heartbeat<C: ConnectionLike + Send>(
&self,
conn: &mut C
) -> OcyResult<()>
Updates a job’s last heartbeat date/time.
sourcepub async fn apply_expiry<C: ConnectionLike + Send>(
&self,
conn: &mut C
) -> OcyResult<bool>
pub async fn apply_expiry<C: ConnectionLike + Send>(
&self,
conn: &mut C
) -> 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 async fn apply_timeouts<C: ConnectionLike + Send>(
&self,
conn: &mut C
) -> OcyResult<bool>
pub async fn apply_timeouts<C: ConnectionLike + Send>(
&self,
conn: &mut C
) -> 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 async fn apply_retries<C: ConnectionLike + Send>(
&self,
conn: &mut C
) -> OcyResult<bool>
pub async fn apply_retries<C: ConnectionLike + Send>(
&self,
conn: &mut C
) -> 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 async fn delete<C: ConnectionLike + Send>(
&self,
conn: &mut C
) -> OcyResult<bool>
pub async fn delete<C: ConnectionLike + Send>(
&self,
conn: &mut C
) -> 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 async fn delete_in_pipe<'b, C: ConnectionLike + Send>(
&self,
conn: &mut C,
pipe: &'b mut Pipeline
) -> OcyResult<&'b mut Pipeline>
pub async fn delete_in_pipe<'b, C: ConnectionLike + Send>(
&self,
conn: &mut C,
pipe: &'b mut Pipeline
) -> OcyResult<&'b mut Pipeline>
Add commands to delete this job status to a pipeline.
Trait Implementations
sourceimpl<'a> ToRedisArgs for &RedisJob<'a>
impl<'a> ToRedisArgs for &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,
This converts the value into a vector of bytes. Each item is a single argument. Most items generate a vector of a single item. Read more
sourcefn write_redis_args<W: ?Sized + RedisWrite>(&self, out: &mut W)
fn write_redis_args<W: ?Sized + RedisWrite>(&self, out: &mut W)
This writes the value into a vector of bytes. Each item is a single argument. Most items generate a single item. Read more
sourcefn describe_numeric_behavior(&self) -> NumericBehavior
fn describe_numeric_behavior(&self) -> NumericBehavior
Returns an information about the contained value with regards
to it’s numeric behavior in a redis context. This is used in
some high level concepts to switch between different implementations
of redis functions (for instance INCR
vs INCRBYFLOAT
). Read more
sourcefn is_single_arg(&self) -> bool
fn is_single_arg(&self) -> bool
Returns an indiciation if the value contained is exactly one
argument. It returns false if it’s zero or more than one. This
is used in some high level functions to intelligently switch
between GET
and MGET
variants. Read more
Auto Trait Implementations
impl<'a> RefUnwindSafe for RedisJob<'a>
impl<'a> Send for RedisJob<'a>
impl<'a> Sync for RedisJob<'a>
impl<'a> Unpin for RedisJob<'a>
impl<'a> UnwindSafe for RedisJob<'a>
Blanket Implementations
sourceimpl<T> BorrowMut<T> for T where
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
const: unstable · sourcefn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
sourceimpl<T> Instrument for T
impl<T> Instrument for T
sourcefn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
sourcefn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
impl<V, T> VZip<V> for T where
V: MultiLane<T>,
impl<V, T> VZip<V> for T where
V: MultiLane<T>,
fn vzip(self) -> V
sourceimpl<T> WithSubscriber for T
impl<T> WithSubscriber for T
sourcefn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self> where
S: Into<Dispatch>,
fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self> where
S: Into<Dispatch>,
Attaches the provided Subscriber
to this type, returning a
WithDispatch
wrapper. Read more
sourcefn with_current_subscriber(self) -> WithDispatch<Self>
fn with_current_subscriber(self) -> WithDispatch<Self>
Attaches the current default Subscriber
to this type, returning a
WithDispatch
wrapper. Read more