Skip to main content

SqliteJobStore

Struct SqliteJobStore 

Source
pub struct SqliteJobStore { /* private fields */ }
Expand description

SQLite-backed job store implementing every job port.

Implementations§

Source§

impl SqliteJobStore

Source

pub const fn new(pool: SqlitePool) -> Self

Source

pub async fn enqueue_in( &self, transaction: &mut Transaction<'_, Sqlite>, record: JobRecord, ) -> Result<EnqueueOutcome, JobError>

Insert the job and its first publication generation inside the caller’s transaction so the business mutation and the durable dispatch commit atomically.

Source

pub async fn ingest_in( &self, transaction: &mut Transaction<'_, Sqlite>, record: JobRecord, ) -> Result<IngestOutcome, JobError>

Insert the job with its publication recorded as already delivered (Scheduler ingestion) inside the caller’s transaction.

Trait Implementations§

Source§

impl Clone for SqliteJobStore

Source§

fn clone(&self) -> SqliteJobStore

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for SqliteJobStore

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl JobPublicationStore for SqliteJobStore

Source§

fn claim_due<'life0, 'life1, 'async_trait>( &'life0 self, worker_execution_id: &'life1 str, limit: usize, claim_expires_at: DateTime<Utc>, now: DateTime<Utc>, ) -> Pin<Box<dyn Future<Output = Result<Vec<JobPublication>, JobError>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait,

Atomically claim up to limit due publications. The returned publications carry the claim’s lease identity.
Source§

fn mark_published<'life0, 'async_trait>( &'life0 self, publication_id: Uuid, lease_id: Uuid, ) -> Pin<Box<dyn Future<Output = Result<(), JobError>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

Mark one publication delivered, fenced by its lease.
Source§

fn mark_failed<'life0, 'life1, 'async_trait>( &'life0 self, publication_id: Uuid, lease_id: Uuid, error: &'life1 str, retry_at: DateTime<Utc>, ) -> Pin<Box<dyn Future<Output = Result<(), JobError>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait,

Record a failed transport send with a retry time, fenced by the publication lease.
Source§

fn recover_expired_claims<'life0, 'async_trait>( &'life0 self, now: DateTime<Utc>, ) -> Pin<Box<dyn Future<Output = Result<usize, JobError>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

Reset expired publication claims to pending. Returns the count.
Source§

impl JobStore for SqliteJobStore

Source§

fn enqueue_with_intent<'life0, 'async_trait>( &'life0 self, record: JobRecord, ) -> Pin<Box<dyn Future<Output = Result<EnqueueOutcome, JobError>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

Atomically insert the job and its first pending publication generation. SQL adapters additionally expose enqueue_in to share the caller’s transaction.
Source§

fn ingest_existing_delivery<'life0, 'async_trait>( &'life0 self, record: JobRecord, ) -> Pin<Box<dyn Future<Output = Result<IngestOutcome, JobError>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

Atomically ingest a delivery that already exists on the transport (Scheduler occurrences): create the job with its publication marked delivered, or locate the existing occurrence, without ever inserting a pending publication.
Source§

fn claim_execution<'life0, 'life1, 'async_trait>( &'life0 self, job_id: Uuid, worker_execution_id: &'life1 str, lease_expires_at: DateTime<Utc>, now: DateTime<Utc>, ) -> Pin<Box<dyn Future<Output = Result<Option<JobClaim>, JobError>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait,

Atomically claim the execution lease for one delivery. The worker_execution_id must be unique per invocation (not a static worker name); the returned claim’s opaque lease_id is the sole mutation authority. Returns None when the job is missing, already leased, not yet available or terminal.
Source§

fn complete<'life0, 'life1, 'async_trait>( &'life0 self, claim: &'life1 JobClaim, now: DateTime<Utc>, ) -> Pin<Box<dyn Future<Output = Result<(), JobError>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait,

Record terminal success and release the lease, fenced by the claim.
Source§

fn schedule_retry_and_publish<'life0, 'life1, 'life2, 'async_trait>( &'life0 self, claim: &'life1 JobClaim, failure_code: &'life2 str, next_available_at: DateTime<Utc>, now: DateTime<Utc>, ) -> Pin<Box<dyn Future<Output = Result<Uuid, JobError>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait, 'life2: 'async_trait,

Atomically record a retryable failure: verify the claim fence, append the attempt, return the job to pending at the next availability time, clear the execution lease and insert the next pending publication generation — all in one transaction, so no intermediate committed state can strand the job.
Source§

fn fail_permanently<'life0, 'life1, 'life2, 'async_trait>( &'life0 self, claim: &'life1 JobClaim, failure_code: &'life2 str, now: DateTime<Utc>, ) -> Pin<Box<dyn Future<Output = Result<(), JobError>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait, 'life2: 'async_trait,

Record terminal failure and release the lease, fenced by the claim.
Source§

fn cancel<'life0, 'async_trait>( &'life0 self, job_id: Uuid, expected_revision: u64, now: DateTime<Utc>, ) -> Pin<Box<dyn Future<Output = Result<(), JobError>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

Operator-guarded cancellation of a non-running job.
Source§

fn retry_failed<'life0, 'async_trait>( &'life0 self, job_id: Uuid, expected_revision: u64, now: DateTime<Utc>, ) -> Pin<Box<dyn Future<Output = Result<DateTime<Utc>, JobError>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

Operator-guarded retry of a permanently failed job: back to pending at a fresh revision with a new pending publication generation, atomically.
Source§

fn recover_expired_leases<'life0, 'async_trait>( &'life0 self, now: DateTime<Utc>, ) -> Pin<Box<dyn Future<Output = Result<usize, JobError>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

Reset expired running leases back to pending and open a pending publication generation for each recovered job. Returns the number recovered.
Source§

fn get<'life0, 'async_trait>( &'life0 self, job_id: Uuid, ) -> Pin<Box<dyn Future<Output = Result<Option<JobRecord>, JobError>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

Source§

fn list_failed<'life0, 'async_trait>( &'life0 self, limit: usize, ) -> Pin<Box<dyn Future<Output = Result<Vec<JobRecord>, JobError>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

Bounded listing of permanently failed jobs for operators.
Source§

impl OverlapLockStore for SqliteJobStore

Source§

fn acquire<'life0, 'life1, 'async_trait>( &'life0 self, overlap_key: &'life1 str, lease_id: Uuid, expires_at: DateTime<Utc>, now: DateTime<Utc>, ) -> Pin<Box<dyn Future<Output = Result<bool, JobError>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait,

Acquire the lock for lease_id until expires_at; false when held.
Source§

fn refresh<'life0, 'life1, 'async_trait>( &'life0 self, overlap_key: &'life1 str, lease_id: Uuid, expires_at: DateTime<Utc>, now: DateTime<Utc>, ) -> Pin<Box<dyn Future<Output = Result<bool, JobError>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait,

Extend a held lock; false when the caller no longer owns it.
Source§

fn release<'life0, 'life1, 'async_trait>( &'life0 self, overlap_key: &'life1 str, lease_id: Uuid, ) -> Pin<Box<dyn Future<Output = Result<(), JobError>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait,

Release a held lock. Releasing an unheld lock is a no-op; releasing another owner’s lock is impossible by construction.
Source§

fn recover_expired<'life0, 'async_trait>( &'life0 self, now: DateTime<Utc>, ) -> Pin<Box<dyn Future<Output = Result<usize, JobError>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

Delete expired locks. Returns the number removed.

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> IntoEither for T

Source§

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 more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

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
Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<T> WithSubscriber for T

Source§

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
Source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more