Skip to main content

SqlQueueBackend

Struct SqlQueueBackend 

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

SQL-backed queue backend (PostgreSQL or SQLite).

Implementations§

Source§

impl SqlQueueBackend

Source

pub async fn connect_sqlite(url: &str) -> Result<Self>

Open a SQLite pool, bootstrap schema, and return a backend.

§Errors

Returns a backend error if the pool connection or schema bootstrap fails.

Source

pub async fn connect_postgres(url: &str) -> Result<Self>

Open a PostgreSQL pool, bootstrap schema, and return a backend.

§Errors

Returns a backend error if the pool connection or schema bootstrap fails.

Source

pub async fn connect_postgres_isolated(url: &str, schema: &str) -> Result<Self>

Connect to PostgreSQL with an isolated schema for parallel tests.

§Errors

Returns a backend error if schema creation, pool connection, or schema bootstrap fails.

Source

pub async fn from_sqlite_pool(pool: Pool<Sqlite>) -> Result<Self>

Wrap an existing SQLite pool (schema bootstrap runs).

§Errors

Returns a backend error if schema bootstrap fails.

Source

pub async fn from_postgres_pool(pool: Pool<Postgres>) -> Result<Self>

Wrap an existing PostgreSQL pool (schema bootstrap runs).

§Errors

Returns a backend error if schema bootstrap fails.

Source

pub const fn pool(&self) -> &SqlPool

Underlying connection pool.

Source

pub const fn dialect(&self) -> SqlDialect

Engine dialect.

Trait Implementations§

Source§

impl Debug for SqlQueueBackend

Source§

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

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

impl QueueBackend for SqlQueueBackend

Source§

fn upsert_job<'life0, 'life1, 'async_trait>( &'life0 self, job: &'life1 Job, ) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait,

Persist or update a job row.
Source§

fn enqueue_with_policies<'life0, 'life1, 'async_trait>( &'life0 self, job: Job, task_config: &'life1 TaskConfig, ) -> Pin<Box<dyn Future<Output = Result<(String, JobEnqueueDisposition)>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait,

Insert job with idempotency semantics (see trait-level contract).
Source§

fn get_job<'life0, 'life1, 'async_trait>( &'life0 self, job_id: &'life1 str, ) -> Pin<Box<dyn Future<Output = Result<Option<Job>>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait,

Load one job by id.
Source§

fn list_jobs<'life0, 'async_trait>( &'life0 self, status_filter: Option<JobStatus>, offset: usize, limit: usize, ) -> Pin<Box<dyn Future<Output = Result<Vec<Job>>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

List jobs with optional status filter and pagination.
Source§

fn cancel_job_if_active<'life0, 'life1, 'async_trait>( &'life0 self, job_id: &'life1 str, ) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait,

Cancel a job if it is still active (queued or running).
Source§

fn try_claim_job<'life0, 'life1, 'async_trait>( &'life0 self, job_id: &'life1 str, ) -> Pin<Box<dyn Future<Output = Result<Option<Job>>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait,

Atomically claim a queued job for execution.
Source§

fn revert_job_to_queued<'life0, 'life1, 'async_trait>( &'life0 self, job_id: &'life1 str, ) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait,

Revert a job to queued (retry path).
Source§

fn distinct_pools_queued<'life0, 'async_trait>( &'life0 self, ) -> Pin<Box<dyn Future<Output = Result<Vec<String>>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

Distinct pool names with queued jobs.
Source§

fn list_queued_for_pool_sorted<'life0, 'life1, 'async_trait>( &'life0 self, pool: &'life1 str, limit: usize, ) -> Pin<Box<dyn Future<Output = Result<Vec<Job>>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait,

Queued jobs for one pool, sorted by priority then created time.
Source§

fn count_jobs<'life0, 'async_trait>( &'life0 self, status_filter: Option<JobStatus>, ) -> Pin<Box<dyn Future<Output = Result<u64>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

Count jobs, optionally filtered by status.
Source§

fn count_jobs_for_task<'life0, 'life1, 'async_trait>( &'life0 self, task_name: &'life1 str, status: Option<JobStatus>, ) -> Pin<Box<dyn Future<Output = Result<u64>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait,

Count jobs for one task, optionally filtered by status.
Source§

fn count_active_jobs_for_task<'life0, 'life1, 'async_trait>( &'life0 self, task_name: &'life1 str, ) -> Pin<Box<dyn Future<Output = Result<u32>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait,

Count active (queued + running) jobs for rate-limit checks.
Source§

fn find_nonterminal_by_idempotency_key<'life0, 'life1, 'async_trait>( &'life0 self, key: &'life1 str, ) -> Pin<Box<dyn Future<Output = Result<Option<String>>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait,

Find non-terminal job by idempotency key. Read more
Source§

fn upsert_run<'life0, 'life1, 'async_trait>( &'life0 self, run: &'life1 Run, ) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait,

Persist or update a run row.
Source§

fn get_run<'life0, 'life1, 'async_trait>( &'life0 self, run_id: &'life1 str, ) -> Pin<Box<dyn Future<Output = Result<Option<Run>>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait,

Load one run by id.
Source§

fn list_runs<'life0, 'life1, 'async_trait>( &'life0 self, job_id_filter: Option<&'life1 str>, offset: usize, limit: usize, ) -> Pin<Box<dyn Future<Output = Result<Vec<Run>>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait,

List runs with optional job filter and pagination.
Source§

fn finish_run<'life0, 'life1, 'async_trait>( &'life0 self, run_id: &'life1 str, status: RunStatus, duration_ms: Option<i64>, error_message: Option<String>, ) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait,

Mark a run terminal with outcome fields.
Source§

fn count_runs<'life0, 'life1, 'async_trait>( &'life0 self, job_id_filter: Option<&'life1 str>, ) -> Pin<Box<dyn Future<Output = Result<u64>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait,

Count runs, optionally filtered by job id.
Source§

fn count_runs_since<'life0, 'async_trait>( &'life0 self, since: DateTime<Utc>, ) -> Pin<Box<dyn Future<Output = Result<u64>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

Count runs with started_at >= since.
Source§

fn task_run_stats<'life0, 'life1, 'async_trait>( &'life0 self, task_name: &'life1 str, ) -> Pin<Box<dyn Future<Output = Result<TaskRunStats>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait,

Aggregate run totals for one task.
Source§

fn get_task_config<'life0, 'life1, 'async_trait>( &'life0 self, task_name: &'life1 str, ) -> Pin<Box<dyn Future<Output = Result<Option<TaskConfig>>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait,

Load task config by name.
Source§

fn upsert_task_config<'life0, 'life1, 'async_trait>( &'life0 self, config: &'life1 TaskConfig, ) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait,

Persist task config.
Source§

fn try_claim_run_lease<'life0, 'life1, 'life2, 'async_trait>( &'life0 self, job_id: &'life1 str, worker_id: &'life2 str, ttl_secs: i64, ) -> Pin<Box<dyn Future<Output = Result<Option<String>>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait, 'life2: 'async_trait,

Attempt to claim a run lease for job_id (stored as lease task id). Read more
Source§

fn extend_lease<'life0, 'life1, 'async_trait>( &'life0 self, lease_id: &'life1 str, ttl_secs: i64, ) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait,

Extend lease TTL for a held lease.
Source§

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

Release a held lease.
Source§

fn expired_lease_job_pairs<'life0, 'async_trait>( &'life0 self, ) -> Pin<Box<dyn Future<Output = Result<Vec<(String, String)>>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

Expired leases as (lease_record_id, job_id).
Source§

fn pop_claim_from_pool<'life0, 'life1, 'async_trait>( &'life0 self, _pool: &'life1 str, ) -> Pin<Box<dyn Future<Output = Result<Option<Job>, BosonError>> + Send + 'async_trait>>
where 'life0: 'async_trait, 'life1: 'async_trait, Self: 'async_trait,

Atomically claim the highest-priority queued job from pool when supported. Read more

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<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
where ST: ?Sized, DT: ?Sized,

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> Read<Exclusive, BecauseExclusive> for T
where T: ?Sized,

Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
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<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V

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