pub struct JobQueue { /* private fields */ }Expand description
Job queue operations.
Implementations§
Source§impl JobQueue
impl JobQueue
Sourcepub async fn claim(
&self,
worker_id: Uuid,
capabilities: &[String],
limit: i32,
) -> Result<Vec<JobRecord>, Error>
pub async fn claim( &self, worker_id: Uuid, capabilities: &[String], limit: i32, ) -> Result<Vec<JobRecord>, Error>
Claim jobs using SKIP LOCKED pattern.
Sourcepub async fn complete(
&self,
job_id: Uuid,
output: Value,
ttl: Option<Duration>,
) -> Result<(), Error>
pub async fn complete( &self, job_id: Uuid, output: Value, ttl: Option<Duration>, ) -> Result<(), Error>
Mark job as completed.
If ttl is provided, sets expires_at for automatic cleanup.
Sourcepub async fn fail(
&self,
job_id: Uuid,
error: &str,
retry_delay: Option<Duration>,
ttl: Option<Duration>,
) -> Result<(), Error>
pub async fn fail( &self, job_id: Uuid, error: &str, retry_delay: Option<Duration>, ttl: Option<Duration>, ) -> Result<(), Error>
Mark job as failed, schedule retry or move to dead letter.
If ttl is provided and job moves to dead_letter, sets expires_at for automatic cleanup.
Sourcepub async fn heartbeat(&self, job_id: Uuid) -> Result<(), Error>
pub async fn heartbeat(&self, job_id: Uuid) -> Result<(), Error>
Update heartbeat for a running job.
Sourcepub async fn update_progress(
&self,
job_id: Uuid,
percent: i32,
message: &str,
) -> Result<(), Error>
pub async fn update_progress( &self, job_id: Uuid, percent: i32, message: &str, ) -> Result<(), Error>
Update job progress.
Sourcepub async fn set_context(
&self,
job_id: Uuid,
context: Value,
) -> Result<(), Error>
pub async fn set_context( &self, job_id: Uuid, context: Value, ) -> Result<(), Error>
Replace persisted job context.
Sourcepub async fn request_cancel(
&self,
job_id: Uuid,
reason: Option<&str>,
) -> Result<bool, Error>
pub async fn request_cancel( &self, job_id: Uuid, reason: Option<&str>, ) -> Result<bool, Error>
Request cancellation for a job.
Sourcepub async fn cancel(
&self,
job_id: Uuid,
reason: Option<&str>,
ttl: Option<Duration>,
) -> Result<(), Error>
pub async fn cancel( &self, job_id: Uuid, reason: Option<&str>, ttl: Option<Duration>, ) -> Result<(), Error>
Mark job as cancelled.
If ttl is provided, sets expires_at for automatic cleanup.
Sourcepub async fn release_stale(
&self,
stale_threshold: Duration,
) -> Result<u64, Error>
pub async fn release_stale( &self, stale_threshold: Duration, ) -> Result<u64, Error>
Release stale jobs back to pending.
Sourcepub async fn cleanup_expired(&self) -> Result<u64, Error>
pub async fn cleanup_expired(&self) -> Result<u64, Error>
Delete expired job records.
Only deletes terminal jobs (completed, cancelled, failed, dead_letter) that have passed their TTL.
Trait Implementations§
Auto Trait Implementations§
impl Freeze for JobQueue
impl !RefUnwindSafe for JobQueue
impl Send for JobQueue
impl Sync for JobQueue
impl Unpin for JobQueue
impl !UnwindSafe for JobQueue
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> FutureExt for T
impl<T> FutureExt for T
Source§fn with_context(self, otel_cx: Context) -> WithContext<Self>
fn with_context(self, otel_cx: Context) -> WithContext<Self>
Source§fn with_current_context(self) -> WithContext<Self>
fn with_current_context(self) -> WithContext<Self>
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§impl<T> IntoRequest<T> for T
impl<T> IntoRequest<T> for T
Source§fn into_request(self) -> Request<T>
fn into_request(self) -> Request<T>
Wrap the input message
T in a tonic::Request