Struct PGMQueueExt

Source
pub struct PGMQueueExt {
    pub url: String,
    pub connection: Pool<Postgres>,
}
Expand description

Main controller for interacting with a managed by the PGMQ Postgres extension.

Fields§

§url: String§connection: Pool<Postgres>

Implementations§

Source§

impl PGMQueueExt

Source

pub async fn new(url: String, max_connections: u32) -> Result<Self, PgmqError>

Initialize a connection to PGMQ/Postgres

Source

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

BYOP - bring your own pool initialize a PGMQ connection with your own SQLx Postgres connection pool

Source

pub async fn init_with_cxn<'c, E: Executor<'c, Database = Postgres>>( &self, executor: E, ) -> Result<bool, PgmqError>

Source

pub async fn init(&self) -> Result<bool, PgmqError>

Source

pub async fn create_with_cxn<'c, E: Executor<'c, Database = Postgres>>( &self, queue_name: &str, executor: E, ) -> Result<bool, PgmqError>

Source

pub async fn create(&self, queue_name: &str) -> Result<bool, PgmqError>

Errors when there is any database error and Ok(false) when the queue already exists.

Source

pub async fn create_unlogged_with_cxn<'c, E: Executor<'c, Database = Postgres>>( &self, queue_name: &str, executor: E, ) -> Result<bool, PgmqError>

Source

pub async fn create_unlogged(&self, queue_name: &str) -> Result<bool, PgmqError>

Errors when there is any database error and Ok(false) when the queue already exists.

Source

pub async fn create_partitioned_with_cxn<'c, E: Executor<'c, Database = Postgres> + Copy>( &self, queue_name: &str, executor: E, ) -> Result<bool, PgmqError>

Source

pub async fn create_partitioned( &self, queue_name: &str, ) -> Result<bool, PgmqError>

Create a new partitioned queue. Errors when there is any database error and Ok(false) when the queue already exists.

Source

pub async fn drop_queue_with_cxn<'c, E: Executor<'c, Database = Postgres>>( &self, queue_name: &str, executor: E, ) -> Result<(), PgmqError>

Source

pub async fn drop_queue(&self, queue_name: &str) -> Result<(), PgmqError>

Drop an existing queue table.

Source

pub async fn purge_queue_with_cxn<'c, E: Executor<'c, Database = Postgres>>( &self, queue_name: &str, executor: E, ) -> Result<i64, PgmqError>

Drop an existing queue table.

Source

pub async fn purge_queue(&self, queue_name: &str) -> Result<i64, PgmqError>

Drop an existing queue table.

Source

pub async fn list_queues_with_cxn<'c, E: Executor<'c, Database = Postgres>>( &self, executor: E, ) -> Result<Option<Vec<PGMQueueMeta>>, PgmqError>

Source

pub async fn list_queues(&self) -> Result<Option<Vec<PGMQueueMeta>>, PgmqError>

List all queues in the Postgres instance.

Source

pub async fn set_vt_with_cxn<'c, E: Executor<'c, Database = Postgres>, T: for<'de> Deserialize<'de>>( &self, queue_name: &str, msg_id: i64, vt: i32, executor: E, ) -> Result<Message<T>, PgmqError>

Source

pub async fn set_vt<T: for<'de> Deserialize<'de>>( &self, queue_name: &str, msg_id: i64, vt: i32, ) -> Result<Message<T>, PgmqError>

Source

pub async fn send_with_cxn<'c, E: Executor<'c, Database = Postgres>, T: Serialize>( &self, queue_name: &str, message: &T, executor: E, ) -> Result<i64, PgmqError>

Source

pub async fn send<T: Serialize>( &self, queue_name: &str, message: &T, ) -> Result<i64, PgmqError>

Source

pub async fn send_delay_with_cxn<'c, E: Executor<'c, Database = Postgres>, T: Serialize>( &self, queue_name: &str, message: &T, delay: u32, executor: E, ) -> Result<i64, PgmqError>

Source

pub async fn send_delay<T: Serialize>( &self, queue_name: &str, message: &T, delay: u32, ) -> Result<i64, PgmqError>

Source

pub async fn read_with_cxn<'c, E: Executor<'c, Database = Postgres>, T: for<'de> Deserialize<'de>>( &self, queue_name: &str, vt: i32, executor: E, ) -> Result<Option<Message<T>>, PgmqError>

Source

pub async fn read<T: for<'de> Deserialize<'de>>( &self, queue_name: &str, vt: i32, ) -> Result<Option<Message<T>>, PgmqError>

Source

pub async fn read_batch_with_poll_with_cxn<'c, E: Executor<'c, Database = Postgres>, T: for<'de> Deserialize<'de>>( &self, queue_name: &str, vt: i32, max_batch_size: i32, poll_timeout: Option<Duration>, poll_interval: Option<Duration>, executor: E, ) -> Result<Option<Vec<Message<T>>>, PgmqError>

Source

pub async fn read_batch_with_poll<T: for<'de> Deserialize<'de>>( &self, queue_name: &str, vt: i32, max_batch_size: i32, poll_timeout: Option<Duration>, poll_interval: Option<Duration>, ) -> Result<Option<Vec<Message<T>>>, PgmqError>

Source

pub async fn archive_with_cxn<'c, E: Executor<'c, Database = Postgres>>( &self, queue_name: &str, msg_id: i64, executor: E, ) -> Result<bool, PgmqError>

Source

pub async fn archive( &self, queue_name: &str, msg_id: i64, ) -> Result<bool, PgmqError>

Move a message to the archive table.

Source

pub async fn archive_batch_with_cxn<'c, E: Executor<'c, Database = Postgres>>( &self, queue_name: &str, msg_ids: &[i64], executor: E, ) -> Result<usize, PgmqError>

Move a slice of messages to the archive table.

Source

pub async fn archive_batch( &self, queue_name: &str, msg_ids: &[i64], ) -> Result<usize, PgmqError>

Move a slice of messages to the archive table.

Source

pub async fn pop_with_cxn<'c, E: Executor<'c, Database = Postgres>, T: for<'de> Deserialize<'de>>( &self, queue_name: &str, executor: E, ) -> Result<Option<Message<T>>, PgmqError>

Source

pub async fn pop<T: for<'de> Deserialize<'de>>( &self, queue_name: &str, ) -> Result<Option<Message<T>>, PgmqError>

Source

pub async fn delete_with_cxn<'c, E: Executor<'c, Database = Postgres>>( &self, queue_name: &str, msg_id: i64, executor: E, ) -> Result<bool, PgmqError>

Source

pub async fn delete( &self, queue_name: &str, msg_id: i64, ) -> Result<bool, PgmqError>

Source

pub async fn delete_batch_with_cxn<'c, E: Executor<'c, Database = Postgres>>( &self, queue_name: &str, msg_id: &[i64], executor: E, ) -> Result<usize, PgmqError>

Source

pub async fn delete_batch( &self, queue_name: &str, msg_id: &[i64], ) -> Result<usize, PgmqError>

Trait Implementations§

Source§

impl Clone for PGMQueueExt

Source§

fn clone(&self) -> PGMQueueExt

Returns a copy of the value. Read more
1.0.0 · Source§

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

Performs copy-assignment from source. Read more
Source§

impl Debug for PGMQueueExt

Source§

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

Formats the value using the given formatter. 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<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<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
Source§

impl<T> ErasedDestructor for T
where T: 'static,