Postgres Message Queue (PGMQ)
The Rust client for PGMQ. This gives you an ORM-like experience with the Postgres extension and makes managing connection pools, transactions, and serialization/deserialization much easier.
Installing PGMQ
PGMQ can be installed into any existing Postgres database using this Rust client.
Run standard Postgres using Docker:
Via CLI
Install the PGMQ Rust CLI:
In Rust
Refer to the install example, or add PGMQ to your Cargo.toml with the cli feature enabled:
use PGMQueueExt;
let db_url = "postgres://postgres:postgres@localhost:5432/postgres".to_string;
let queue = new
.await
.expect;
queue.install_sql.await;
Examples
The project contains several examples. You can run these using Cargo.
A basic example displaying the primary features:
How to install PGMQ using the Rust client from within your application:
Serialization and Deserialization
Messages can be parsed as serde_json::Value or into a struct of your design. queue.read() returns an Result<Option<Message<T>>, PgmqError>
where T is the type of the message on the queue. It returns an error when there is an issue parsing the message (PgmqError::JsonParsingError) or if PGMQ is unable to reach postgres (PgmqError::DatabaseError).
License: PostgreSQL