pub struct PostgresQueue { /* private fields */ }Expand description
A Queue in a PostgreSQL table.
Implementations§
Source§impl PostgresQueue
impl PostgresQueue
Sourcepub fn with_table(pool: PgPool, table: &str) -> Result<Self, QueueError>
pub fn with_table(pool: PgPool, table: &str) -> Result<Self, QueueError>
A queue in the table table.
§Errors
When table is not a plain SQL identifier: ASCII letters, digits and
underscores, not starting with a digit, optionally prefixed by a schema
of the same shape and a dot.
Sourcepub async fn initialize(&self) -> Result<(), QueueError>
pub async fn initialize(&self) -> Result<(), QueueError>
Create the table and its index if they do not exist.
Safe to run from every process at start-up, including both colours of
a blue/green deploy at once. An application that changes its schema
only through its own migrations creates the table there instead, from
PostgresQueue::schema.
§Errors
When the database refuses.
Sourcepub fn schema(table: &str) -> Vec<String>
pub fn schema(table: &str) -> Vec<String>
The statements that create a queue table named table and its
indexes, each safe to run again, and bring one made before ordering
keys up to date. What PostgresQueue::initialize runs, for an
application to put in a migration of its own.
Sourcepub async fn prune_failed(&self, age: Duration) -> Result<u64, QueueError>
pub async fn prune_failed(&self, age: Duration) -> Result<u64, QueueError>
Trait Implementations§
Source§impl Clone for PostgresQueue
impl Clone for PostgresQueue
Source§fn clone(&self) -> PostgresQueue
fn clone(&self) -> PostgresQueue
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl Debug for PostgresQueue
impl Debug for PostgresQueue
Source§impl Queue for PostgresQueue
impl Queue for PostgresQueue
Source§async fn enqueue(
&self,
queue: &str,
payloads: Vec<Value>,
) -> Result<(), QueueError>
async fn enqueue( &self, queue: &str, payloads: Vec<Value>, ) -> Result<(), QueueError>
payloads in queue, due now.Source§async fn enqueue_ordered(
&self,
queue: &str,
jobs: Vec<(String, Value)>,
) -> Result<(), QueueError>
async fn enqueue_ordered( &self, queue: &str, jobs: Vec<(String, Value)>, ) -> Result<(), QueueError>
jobs in queue, due now, each with its ordering key. A job is
not claimed while another with the same key, queued before it in any
queue, is still waiting, claimed or due to be retried; once that one
is complete or failed, the next is. Jobs with different keys, and
jobs with none, are claimed as they come due.Source§async fn claim(
&self,
queue: &str,
limit: usize,
lease: Duration,
) -> Result<Vec<Job>, QueueError>
async fn claim( &self, queue: &str, limit: usize, lease: Duration, ) -> Result<Vec<Job>, QueueError>
limit due jobs from queue for lease. None of them is
claimed again until the lease lapses.Source§async fn complete(&self, job: &str) -> Result<(), QueueError>
async fn complete(&self, job: &str) -> Result<(), QueueError>
Source§async fn retry(
&self,
job: &str,
delay: Duration,
message: &str,
) -> Result<(), QueueError>
async fn retry( &self, job: &str, delay: Duration, message: &str, ) -> Result<(), QueueError>
delay.Auto Trait Implementations§
impl !RefUnwindSafe for PostgresQueue
impl !UnwindSafe for PostgresQueue
impl Freeze for PostgresQueue
impl Send for PostgresQueue
impl Sync for PostgresQueue
impl Unpin for PostgresQueue
impl UnsafeUnpin for PostgresQueue
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
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<Q> DynQueue for Qwhere
Q: Queue,
impl<Q> DynQueue for Qwhere
Q: Queue,
Source§fn enqueue<'a>(
&'a self,
queue: &'a str,
payloads: Vec<Value>,
) -> Pin<Box<dyn Future<Output = Result<(), QueueError>> + Send + 'a>>
fn enqueue<'a>( &'a self, queue: &'a str, payloads: Vec<Value>, ) -> Pin<Box<dyn Future<Output = Result<(), QueueError>> + Send + 'a>>
Source§fn enqueue_ordered<'a>(
&'a self,
queue: &'a str,
jobs: Vec<(String, Value)>,
) -> Pin<Box<dyn Future<Output = Result<(), QueueError>> + Send + 'a>>
fn enqueue_ordered<'a>( &'a self, queue: &'a str, jobs: Vec<(String, Value)>, ) -> Pin<Box<dyn Future<Output = Result<(), QueueError>> + Send + 'a>>
Source§fn claim<'a>(
&'a self,
queue: &'a str,
limit: usize,
lease: Duration,
) -> Pin<Box<dyn Future<Output = Result<Vec<Job>, QueueError>> + Send + 'a>>
fn claim<'a>( &'a self, queue: &'a str, limit: usize, lease: Duration, ) -> Pin<Box<dyn Future<Output = Result<Vec<Job>, QueueError>> + Send + 'a>>
Source§fn complete<'a>(
&'a self,
id: &'a str,
) -> Pin<Box<dyn Future<Output = Result<(), QueueError>> + Send + 'a>>
fn complete<'a>( &'a self, id: &'a str, ) -> Pin<Box<dyn Future<Output = Result<(), QueueError>> + Send + 'a>>
Source§fn retry<'a>(
&'a self,
id: &'a str,
delay: Duration,
error: &'a str,
) -> Pin<Box<dyn Future<Output = Result<(), QueueError>> + Send + 'a>>
fn retry<'a>( &'a self, id: &'a str, delay: Duration, error: &'a str, ) -> Pin<Box<dyn Future<Output = Result<(), QueueError>> + Send + 'a>>
§impl<T> Instrument for T
impl<T> Instrument for T
§fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
fn instrument(self, span: Span) -> 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