Skip to main content

Store

Struct Store 

Source
pub struct Store { /* private fields */ }

Implementations§

Source§

impl Store

Source

pub async fn connect(database_url: &str) -> Result<Self, PostgresError>

Source

pub async fn connect_with_config( config: &StoreConfig, ) -> Result<Self, PostgresError>

Source

pub fn from_pool(pool: PgPool) -> Self

Source

pub fn from_pools(pool: PgPool, listener_pool: PgPool) -> Self

Source

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

Source

pub async fn health(&self) -> Result<(), PostgresError>

Source

pub async fn storage_protocol_version(&self) -> Result<u32, PostgresError>

Source

pub async fn storage_protocol_range( &self, ) -> Result<StorageProtocolRange, PostgresError>

Source

pub async fn ensure_storage_protocol( &self, client: StorageProtocolRange, ) -> Result<Option<StorageProtocolRange>, PostgresError>

Returns None when the schema is absent, so a caller may still migrate it.

Source

pub async fn ready_listener( &self, queue_name: &QueueName, ) -> Result<ReadyListener, PostgresError>

Source

pub async fn ready_listener_for( &self, queue_names: &[QueueName], ) -> Result<ReadyListener, PostgresError>

Source

pub async fn result_listener( &self, task_id: TaskId, ) -> Result<ReadyListener, PostgresError>

Source

pub async fn register_worker( &self, worker_id: WorkerId, queue_name: &QueueName, version: &str, capabilities: &[(TaskName, HandlerVersion, RetryPolicy)], ttl: Duration, ) -> Result<(), PostgresError>

Source

pub async fn heartbeat_worker( &self, worker_id: WorkerId, ttl: Duration, draining: bool, ) -> Result<bool, PostgresError>

Source

pub async fn live_worker_count( &self, queue_name: &QueueName, ) -> Result<u64, PostgresError>

Counts workers the database still considers live, which is not the same as the number of processes reporting metrics: a worker whose heartbeat fails keeps reporting and stops counting.

Source

pub async fn get_worker( &self, worker_id: WorkerId, ) -> Result<Option<WorkerRecord>, PostgresError>

Source

pub async fn migrate(&self) -> Result<(), PostgresError>

Source

pub async fn configure_grants( &self, owner: &str, producer: &str, worker: &str, observer: &str, administrator: &str, ) -> Result<(), PostgresError>

Source

pub async fn put_queue( &self, config: &QueueConfig, ) -> Result<Queue, PostgresError>

Source

pub async fn get_queue( &self, queue_name: &QueueName, ) -> Result<Option<Queue>, PostgresError>

Source

pub async fn queue_demand( &self, queue_name: &QueueName, capabilities: &[(TaskName, HandlerVersion)], ) -> Result<QueueDemand, PostgresError>

Source

pub async fn set_queue_paused( &self, queue_name: &QueueName, paused: bool, ) -> Result<Option<Queue>, PostgresError>

Source

pub async fn put_schedule( &self, config: &ScheduleConfig, ) -> Result<Schedule, PostgresError>

Source

pub async fn get_schedule( &self, schedule_id: ScheduleId, ) -> Result<Option<Schedule>, PostgresError>

Source

pub async fn set_schedule_paused( &self, schedule_id: ScheduleId, paused: bool, ) -> Result<Option<Schedule>, PostgresError>

Source

pub async fn delete_schedule( &self, schedule_id: ScheduleId, ) -> Result<bool, PostgresError>

Source

pub async fn materialize_due_schedules( &self, limit: u16, ) -> Result<u64, PostgresError>

Source

pub async fn next_schedule_delay( &self, ) -> Result<Option<Duration>, PostgresError>

Source

pub async fn next_task_delay( &self, queue_name: &QueueName, capabilities: &[(TaskName, HandlerVersion)], ) -> Result<Option<Duration>, PostgresError>

Source

pub async fn delete_expired_terminal( &self, queue_name: &QueueName, limit: u16, ) -> Result<u64, PostgresError>

Source

pub async fn delete_expired_idempotency_keys( &self, queue_name: &QueueName, limit: u16, ) -> Result<u64, PostgresError>

Source

pub async fn enqueue( &self, request: &EnqueueRequest, ) -> Result<EnqueueResult, PostgresError>

Source

pub async fn spawn_task( &self, request: SpawnRequest<'_>, ) -> Result<Option<EnqueueResult>, PostgresError>

Source

pub async fn enqueue_on( connection: &mut PgConnection, request: &EnqueueRequest, ) -> Result<EnqueueResult, PostgresError>

Source

pub async fn enqueue_many( &self, requests: &[EnqueueRequest], ) -> Result<Vec<EnqueueResult>, PostgresError>

Source

pub async fn enqueue_many_on( connection: &mut PgConnection, requests: &[EnqueueRequest], ) -> Result<Vec<EnqueueResult>, PostgresError>

Source

pub async fn claim( &self, queue_name: &QueueName, worker_id: WorkerId, capabilities: &[(TaskName, HandlerVersion)], limit: u16, lease_duration: Duration, ) -> Result<Vec<Task>, PostgresError>

Source

pub async fn get_task( &self, task_id: TaskId, ) -> Result<Option<Task>, PostgresError>

Source

pub async fn task_count_by_state( &self, queue_name: &QueueName, state: TaskState, ) -> Result<u64, PostgresError>

Source

pub async fn get_checkpoint( &self, task_id: TaskId, handler_version: HandlerVersion, step_name: &StepName, occurrence: u32, ) -> Result<Option<Checkpoint>, PostgresError>

Source

pub async fn commit_checkpoint( &self, task_id: TaskId, attempt: u16, lease_token: LeaseToken, step_name: &StepName, occurrence: u32, value: &Value, ) -> Result<Option<Checkpoint>, PostgresError>

Source

pub async fn sleep_until( &self, task_id: TaskId, attempt: u16, lease_token: LeaseToken, step_name: &StepName, occurrence: u32, wake_at: DateTime<Utc>, ) -> Result<Option<DateTime<Utc>>, PostgresError>

Source

pub async fn sleep_for( &self, task_id: TaskId, attempt: u16, lease_token: LeaseToken, step_name: &StepName, occurrence: u32, duration: Duration, ) -> Result<Option<DateTime<Utc>>, PostgresError>

Source

pub async fn emit_signal( &self, task_id: TaskId, signal_name: &SignalName, occurrence: u32, value: &Value, ) -> Result<Signal, PostgresError>

Source

pub async fn wait_for_signal( &self, request: SignalWaitRequest<'_>, ) -> Result<Option<SignalWait>, PostgresError>

Source

pub async fn wait_for_result( &self, request: ResultWaitRequest<'_>, ) -> Result<Option<ResultWait>, PostgresError>

Source

pub async fn task_result( &self, task_id: TaskId, ) -> Result<Option<TaskResult>, PostgresError>

Source

pub async fn wait_for_task_result( &self, task_id: TaskId, timeout: Option<Duration>, ) -> Result<TaskResultWait, PostgresError>

Source

pub async fn recover_wait_timeouts( &self, limit: u16, ) -> Result<u64, PostgresError>

Source

pub async fn recover_result_wait_timeouts( &self, limit: u16, ) -> Result<u64, PostgresError>

Source

pub async fn next_wait_delay(&self) -> Result<Option<Duration>, PostgresError>

Source

pub async fn cancel(&self, task_id: TaskId) -> Result<bool, PostgresError>

Source

pub async fn renew_lease( &self, task_id: TaskId, attempt: u16, lease_token: LeaseToken, lease_duration: Duration, ) -> Result<bool, PostgresError>

Source

pub async fn renew_leases( &self, leases: &[LeaseRenewal], lease_duration: Duration, ) -> Result<Vec<TaskId>, PostgresError>

Source

pub async fn complete( &self, task_id: TaskId, attempt: u16, lease_token: LeaseToken, result: Option<&Value>, ) -> Result<bool, PostgresError>

Source

pub async fn fail( &self, task_id: TaskId, attempt: u16, lease_token: LeaseToken, error: &Value, retry_after: Option<Duration>, ) -> Result<Option<TaskState>, PostgresError>

Source

pub async fn recover_expired( &self, queue_name: &QueueName, limit: u16, ) -> Result<u64, PostgresError>

Trait Implementations§

Source§

impl Clone for Store

Source§

fn clone(&self) -> Store

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 Store

Source§

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

Formats the value using the given formatter. Read more

Auto Trait Implementations§

§

impl !RefUnwindSafe for Store

§

impl !UnwindSafe for Store

§

impl Freeze for Store

§

impl Send for Store

§

impl Sync for Store

§

impl Unpin for Store

§

impl UnsafeUnpin for Store

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> 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> FutureExt for T

Source§

fn with_context(self, otel_cx: Context) -> WithContext<Self>

Attaches the provided Context to this type, returning a WithContext wrapper. Read more
Source§

fn with_current_context(self) -> WithContext<Self>

Attaches the current Context to this type, returning a WithContext wrapper. Read more
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> 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<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