Crates.io | pgmq-rs |
lib.rs | pgmq-rs |
version | 0.0.1-alpha |
source | src |
created_at | 2023-01-05 16:08:35.707982 |
updated_at | 2023-01-05 16:08:35.707982 |
description | A Rust client for Postgres Message Queues |
homepage | https://www.coredb.io |
repository | |
max_upload_size | |
id | 751637 |
size | 49,784 |
docker run -d --name postgres -e POSTGRES_PASSWORD=postgres -p 5432:5432 postgres
use pgmq_rs::{Message, PGMQueue, PGMQueueConfig};
let qconfig = PGMQueueConfig {
queue_name: "myqueue".to_owned(),
url: "postgres://postgres:postgres@0.0.0.0:5432".to_owned(),
vt: 30,
delay: 0,
};
let queue: PGMQueue = qconfig.init().await;
queue.create().await?;
let msg = serde_json::json!({
"foo": "bar"
});
let msg_id = queue.enqueue(&msg).await;
No messages are returned when the queue is empty or all messages are invisible.
Reading a message will make it invisible for the duration of the visibility timeout (vt).
let read_msg: Message = queue.read().await.unwrap();
Remove the message from the queue when you are done with it.
let deleted = queue.delete(&read_msg.msg_id).await;