pub struct WorkerUtilsWithExecutor<E> { /* private fields */ }Expand description
A scoped WorkerUtils facade that routes operations through a caller-provided executor.
Use WorkerUtils::with_executor when job operations must participate in an existing
transaction. The caller owns the executor lifecycle and remains responsible for committing or
rolling back transactions.
Maintenance operations that manage their own transaction or shared state (cleanup,
migrate, and stale-worker sweeps) remain available only on WorkerUtils.
Implementations§
Source§impl<E> WorkerUtilsWithExecutor<E>where
E: DbExecutorArg,
impl<E> WorkerUtilsWithExecutor<E>where
E: DbExecutorArg,
Sourcepub fn into_inner(self) -> WorkerUtils
pub fn into_inner(self) -> WorkerUtils
Returns the configured WorkerUtils, releasing the injected executor.
Sourcepub async fn add_job<T>(
&mut self,
payload: T,
spec: JobSpec,
) -> Result<Job, GraphileWorkerError>where
T: TaskHandler,
pub async fn add_job<T>(
&mut self,
payload: T,
spec: JobSpec,
) -> Result<Job, GraphileWorkerError>where
T: TaskHandler,
Adds a job to the queue with type safety.
Sourcepub async fn add_raw_job<P>(
&mut self,
identifier: &str,
payload: P,
spec: JobSpec,
) -> Result<Job, GraphileWorkerError>where
P: Serialize,
pub async fn add_raw_job<P>(
&mut self,
identifier: &str,
payload: P,
spec: JobSpec,
) -> Result<Job, GraphileWorkerError>where
P: Serialize,
Adds a job to the queue with a raw identifier and payload.
Sourcepub async fn add_jobs<T>(
&mut self,
jobs: &[(T, &JobSpec)],
) -> Result<Vec<Job>, GraphileWorkerError>where
T: TaskHandler + Clone,
pub async fn add_jobs<T>(
&mut self,
jobs: &[(T, &JobSpec)],
) -> Result<Vec<Job>, GraphileWorkerError>where
T: TaskHandler + Clone,
Adds multiple jobs of the same type in one database operation.
Sourcepub async fn add_raw_jobs(
&mut self,
jobs: &[RawJobSpec],
) -> Result<Vec<Job>, GraphileWorkerError>
pub async fn add_raw_jobs( &mut self, jobs: &[RawJobSpec], ) -> Result<Vec<Job>, GraphileWorkerError>
Adds multiple jobs with raw identifiers and payloads in one database operation.
Sourcepub async fn add_batch_job<T>(
&mut self,
payloads: Vec<T>,
spec: JobSpec,
) -> Result<Job, GraphileWorkerError>where
T: BatchTaskHandler,
pub async fn add_batch_job<T>(
&mut self,
payloads: Vec<T>,
spec: JobSpec,
) -> Result<Job, GraphileWorkerError>where
T: BatchTaskHandler,
Adds a batch job to the queue with type safety.
Sourcepub async fn remove_job(
&mut self,
job_key: &str,
) -> Result<(), GraphileWorkerError>
pub async fn remove_job( &mut self, job_key: &str, ) -> Result<(), GraphileWorkerError>
Removes a job from the queue by its job key.
Sourcepub async fn complete_jobs(
&mut self,
ids: &[i64],
) -> Result<Vec<DbJob>, GraphileWorkerError>
pub async fn complete_jobs( &mut self, ids: &[i64], ) -> Result<Vec<DbJob>, GraphileWorkerError>
Marks multiple jobs as completed.
Sourcepub async fn permanently_fail_jobs(
&mut self,
ids: &[i64],
reason: &str,
) -> Result<Vec<DbJob>, GraphileWorkerError>
pub async fn permanently_fail_jobs( &mut self, ids: &[i64], reason: &str, ) -> Result<Vec<DbJob>, GraphileWorkerError>
Marks multiple jobs as permanently failed with a reason.
Sourcepub async fn reschedule_jobs(
&mut self,
ids: &[i64],
options: RescheduleJobOptions,
) -> Result<Vec<DbJob>, GraphileWorkerError>
pub async fn reschedule_jobs( &mut self, ids: &[i64], options: RescheduleJobOptions, ) -> Result<Vec<DbJob>, GraphileWorkerError>
Reschedules multiple jobs with new parameters.
Sourcepub async fn list_active_workers(
&mut self,
sweep_threshold: Duration,
) -> Result<Vec<ActiveWorkerRow>, GraphileWorkerError>
pub async fn list_active_workers( &mut self, sweep_threshold: Duration, ) -> Result<Vec<ActiveWorkerRow>, GraphileWorkerError>
Lists workers registered in the heartbeat table.
Sourcepub async fn force_unlock_workers(
&mut self,
worker_ids: &[&str],
) -> Result<(), GraphileWorkerError>
pub async fn force_unlock_workers( &mut self, worker_ids: &[&str], ) -> Result<(), GraphileWorkerError>
Force unlocks worker records in the database.
Auto Trait Implementations§
impl<E> !RefUnwindSafe for WorkerUtilsWithExecutor<E>
impl<E> !UnwindSafe for WorkerUtilsWithExecutor<E>
impl<E> Freeze for WorkerUtilsWithExecutor<E>where
E: Freeze,
impl<E> Send for WorkerUtilsWithExecutor<E>where
E: Send,
impl<E> Sync for WorkerUtilsWithExecutor<E>where
E: Sync,
impl<E> Unpin for WorkerUtilsWithExecutor<E>where
E: Unpin,
impl<E> UnsafeUnpin for WorkerUtilsWithExecutor<E>where
E: UnsafeUnpin,
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
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>
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>
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