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
impl PGMQueueExt
Sourcepub async fn new(url: String, max_connections: u32) -> Result<Self, PgmqError>
pub async fn new(url: String, max_connections: u32) -> Result<Self, PgmqError>
Initialize a connection to PGMQ/Postgres
Sourcepub async fn new_with_pool(pool: Pool<Postgres>) -> Self
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
pub async fn init_with_cxn<'c, E: Executor<'c, Database = Postgres>>( &self, executor: E, ) -> Result<bool, PgmqError>
pub async fn init(&self) -> Result<bool, PgmqError>
pub async fn create_with_cxn<'c, E: Executor<'c, Database = Postgres>>( &self, queue_name: &str, executor: E, ) -> Result<bool, PgmqError>
Sourcepub async fn create(&self, queue_name: &str) -> Result<bool, PgmqError>
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.
pub async fn create_unlogged_with_cxn<'c, E: Executor<'c, Database = Postgres>>( &self, queue_name: &str, executor: E, ) -> Result<bool, PgmqError>
Sourcepub async fn create_unlogged(&self, queue_name: &str) -> Result<bool, PgmqError>
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.
pub async fn create_partitioned_with_cxn<'c, E: Executor<'c, Database = Postgres> + Copy>( &self, queue_name: &str, executor: E, ) -> Result<bool, PgmqError>
Sourcepub async fn create_partitioned(
&self,
queue_name: &str,
) -> Result<bool, PgmqError>
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.
pub async fn drop_queue_with_cxn<'c, E: Executor<'c, Database = Postgres>>( &self, queue_name: &str, executor: E, ) -> Result<(), PgmqError>
Sourcepub async fn drop_queue(&self, queue_name: &str) -> Result<(), PgmqError>
pub async fn drop_queue(&self, queue_name: &str) -> Result<(), PgmqError>
Drop an existing queue table.
Sourcepub async fn purge_queue_with_cxn<'c, E: Executor<'c, Database = Postgres>>(
&self,
queue_name: &str,
executor: E,
) -> Result<i64, PgmqError>
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.
Sourcepub async fn purge_queue(&self, queue_name: &str) -> Result<i64, PgmqError>
pub async fn purge_queue(&self, queue_name: &str) -> Result<i64, PgmqError>
Drop an existing queue table.
pub async fn list_queues_with_cxn<'c, E: Executor<'c, Database = Postgres>>( &self, executor: E, ) -> Result<Option<Vec<PGMQueueMeta>>, PgmqError>
Sourcepub async fn list_queues(&self) -> Result<Option<Vec<PGMQueueMeta>>, PgmqError>
pub async fn list_queues(&self) -> Result<Option<Vec<PGMQueueMeta>>, PgmqError>
List all queues in the Postgres instance.
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>
pub async fn set_vt<T: for<'de> Deserialize<'de>>( &self, queue_name: &str, msg_id: i64, vt: i32, ) -> Result<Message<T>, PgmqError>
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>
pub async fn send<T: Serialize>( &self, queue_name: &str, message: &T, ) -> Result<i64, PgmqError>
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>
pub async fn send_delay<T: Serialize>( &self, queue_name: &str, message: &T, delay: u32, ) -> Result<i64, PgmqError>
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>
pub async fn read<T: for<'de> Deserialize<'de>>( &self, queue_name: &str, vt: i32, ) -> Result<Option<Message<T>>, PgmqError>
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>
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>
pub async fn archive_with_cxn<'c, E: Executor<'c, Database = Postgres>>( &self, queue_name: &str, msg_id: i64, executor: E, ) -> Result<bool, PgmqError>
Sourcepub async fn archive(
&self,
queue_name: &str,
msg_id: i64,
) -> Result<bool, PgmqError>
pub async fn archive( &self, queue_name: &str, msg_id: i64, ) -> Result<bool, PgmqError>
Move a message to the archive table.
Sourcepub async fn archive_batch_with_cxn<'c, E: Executor<'c, Database = Postgres>>(
&self,
queue_name: &str,
msg_ids: &[i64],
executor: E,
) -> Result<usize, PgmqError>
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.
Sourcepub async fn archive_batch(
&self,
queue_name: &str,
msg_ids: &[i64],
) -> Result<usize, PgmqError>
pub async fn archive_batch( &self, queue_name: &str, msg_ids: &[i64], ) -> Result<usize, PgmqError>
Move a slice of messages to the archive table.
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>
pub async fn pop<T: for<'de> Deserialize<'de>>( &self, queue_name: &str, ) -> Result<Option<Message<T>>, PgmqError>
pub async fn delete_with_cxn<'c, E: Executor<'c, Database = Postgres>>( &self, queue_name: &str, msg_id: i64, executor: E, ) -> Result<bool, PgmqError>
pub async fn delete( &self, queue_name: &str, msg_id: i64, ) -> Result<bool, PgmqError>
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>
pub async fn delete_batch( &self, queue_name: &str, msg_id: &[i64], ) -> Result<usize, PgmqError>
Trait Implementations§
Source§impl Clone for PGMQueueExt
impl Clone for PGMQueueExt
Source§fn clone(&self) -> PGMQueueExt
fn clone(&self) -> PGMQueueExt
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source
. Read moreAuto Trait Implementations§
impl Freeze for PGMQueueExt
impl !RefUnwindSafe for PGMQueueExt
impl Send for PGMQueueExt
impl Sync for PGMQueueExt
impl Unpin for PGMQueueExt
impl !UnwindSafe for PGMQueueExt
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
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> 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