pub struct JobQueue { /* private fields */ }Expand description
Job queue that manages job lifecycle
Implementations§
Source§impl JobQueue
impl JobQueue
Sourcepub fn new(datastore: Arc<dyn Datastore>, config: JobQueueConfig) -> Self
pub fn new(datastore: Arc<dyn Datastore>, config: JobQueueConfig) -> Self
Create a new job queue
Sourcepub fn with_datastore(datastore: Arc<dyn Datastore>) -> Self
pub fn with_datastore(datastore: Arc<dyn Datastore>) -> Self
Create a new job queue with default configuration
Sourcepub fn register<T>(&self) -> JobResult<()>where
T: BackgroundJob + for<'de> Deserialize<'de> + Send + Sync + 'static,
T::Output: Send + 'static,
pub fn register<T>(&self) -> JobResult<()>where
T: BackgroundJob + for<'de> Deserialize<'de> + Send + Sync + 'static,
T::Output: Send + 'static,
Sourcepub async fn claim_next_job(&self) -> JobResult<Option<Job>>
pub async fn claim_next_job(&self) -> JobResult<Option<Job>>
Claim the next available job for processing
Sourcepub async fn complete_job(&self, job: Job) -> JobResult<()>
pub async fn complete_job(&self, job: Job) -> JobResult<()>
Handle job completion
Sourcepub async fn cancel_job(&self, job: Job) -> JobResult<()>
pub async fn cancel_job(&self, job: Job) -> JobResult<()>
Cancel a pending or failed job
Sourcepub async fn start_worker(&self) -> JobResult<()>
pub async fn start_worker(&self) -> JobResult<()>
Run the worker loop for this queue
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> 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 more