rsmq_async_lite

Crates.iorsmq_async_lite
lib.rsrsmq_async_lite
version2.1.1
sourcesrc
created_at2020-12-05 18:08:21.509803
updated_at2021-03-03 12:39:39.414067
descriptionAsync RSMQ port to rust. RSMQ is a simple redis queue system that works in any redis v2.4+. It contains the same methods as the original one in https://github.com/smrchy/rsmq
homepagehttps://crates.io/crates/rsmq_async
repositoryhttps://github.com/Couragium/rsmq-async-rs
max_upload_size
id319904
size40,277
Cheng JIANG (GopherJ)

documentation

https://docs.rs/rsmq_async/

README

RSMQ in async Rust

RSMQ port to async rust. RSMQ is a simple redis queue system that works in any redis v2.6+. It contains the same methods as the original one in https://github.com/smrchy/rsmq

This crate uses async in the implementation. If you want to use it in your sync code you can use tokio "block_on" method. Async was used in order to simplify the code and allow 1-to-1 port oft he JS code.

Crates.io Crates.io dependency status

Installation

Check https://crates.io/crates/rsmq_async

Async executor

Since version 0.16 where this pull request was merged redis dependency supports tokio and async_std executors. By default it will guess what you are using when creating the connection. You can check redis Cargo.tolm for the flags async-std-comp and tokio-comp in order to fice one or the other.

Example

use rsmq_async::Rsmq;

#[tokio::main]
async fn main() {
    let mut rsmq = Rsmq::<String>::new(Default::default())
        .await
        .expect("connection failed");

    rsmq.create_queue("myqueue", None, None, None)
        .await
        .expect("failed to create queue");

    rsmq.send_message("myqueue", &"testmessage".to_string(), None)
        .await
        .expect("failed to send message");

    let message = rsmq
        .receive_message("myqueue", None)
        .await
        .expect("cannot receive message");

    if let Some(message) = message {
        rsmq.delete_message("myqueue", &message.id).await;
    }
}
Commit count: 89

cargo fmt