diff --git a/Cargo.toml b/Cargo.toml index 1654de2..9906100 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -12,16 +12,15 @@ readme = "README.md" [dependencies] lazy_static = "^1" -rand = "^0.8" +rand = "^0.9" radix_fmt = "^1" -bb8 = "^0.8" -thiserror = "^1" -redis = { version = "^0.27", default-features = false, features = [ +bb8 = "^0.9" +thiserror = "^2" +redis = { version = "^0.28", default-features = false, features = [ "acl", "keep-alive", "script", ] } -async-trait = "^0.1" tokio = { version = "^1", optional = true } [dev-dependencies] diff --git a/src/functions.rs b/src/functions.rs index 1e6f287..1de6393 100644 --- a/src/functions.rs +++ b/src/functions.rs @@ -586,7 +586,7 @@ impl RsmqFunctions { fn make_id(len: usize) -> RsmqResult { let possible = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789"; - let mut rng = rand::thread_rng(); + let mut rng = rand::rng(); let mut id = String::with_capacity(len); diff --git a/src/multiplexed_facade.rs b/src/multiplexed_facade.rs index 277fe2d..cfa0a05 100644 --- a/src/multiplexed_facade.rs +++ b/src/multiplexed_facade.rs @@ -64,7 +64,6 @@ impl Rsmq { } } -#[async_trait::async_trait] impl RsmqConnection for Rsmq { async fn change_message_visibility( &mut self, diff --git a/src/pooled_facade.rs b/src/pooled_facade.rs index f201dde..ce0e457 100644 --- a/src/pooled_facade.rs +++ b/src/pooled_facade.rs @@ -3,7 +3,6 @@ use crate::r#trait::RsmqConnection; use crate::types::RedisBytes; use crate::types::{RsmqMessage, RsmqOptions, RsmqQueueAttributes}; use crate::RsmqResult; -use async_trait::async_trait; use core::convert::TryFrom; use redis::RedisError; use std::marker::PhantomData; @@ -20,7 +19,6 @@ impl RedisConnectionManager { } } -#[async_trait] impl bb8::ManageConnection for RedisConnectionManager { type Connection = redis::aio::MultiplexedConnection; type Error = RedisError; @@ -142,7 +140,6 @@ impl PooledRsmq { } } -#[async_trait::async_trait] impl RsmqConnection for PooledRsmq { async fn change_message_visibility( &mut self, diff --git a/src/sync_facade.rs b/src/sync_facade.rs index 9aa9755..ccb980d 100644 --- a/src/sync_facade.rs +++ b/src/sync_facade.rs @@ -66,7 +66,6 @@ impl RsmqSync { } } -#[async_trait::async_trait] impl RsmqConnection for RsmqSync { async fn change_message_visibility( &mut self, diff --git a/src/trait.rs b/src/trait.rs index 737389e..d73b733 100644 --- a/src/trait.rs +++ b/src/trait.rs @@ -2,19 +2,19 @@ use crate::types::RedisBytes; use crate::types::{RsmqMessage, RsmqQueueAttributes}; use crate::RsmqResult; use core::convert::TryFrom; +use std::future::Future; use std::time::Duration; -#[async_trait::async_trait] pub trait RsmqConnection { /// Change the hidden time of a already sent message. /// /// `hidden` has a max time of 9_999_999 for compatibility reasons to this library JS version counterpart - async fn change_message_visibility( + fn change_message_visibility( &mut self, qname: &str, message_id: &str, hidden: Duration, - ) -> RsmqResult<()>; + ) -> impl Future> + Send; /// Creates a new queue. Attributes can be later modified with "set_queue_attributes" method /// @@ -25,53 +25,60 @@ pub trait RsmqConnection { /// /// maxsize: Maximum size in bytes of each message in the queue. Needs to be between 1024 or 65536 or -1 (unlimited /// size) - async fn create_queue( + fn create_queue( &mut self, qname: &str, hidden: Option, delay: Option, maxsize: Option, - ) -> RsmqResult<()>; + ) -> impl Future> + Send; /// Deletes a message from the queue. /// /// Important to use when you are using receive_message. - async fn delete_message(&mut self, qname: &str, id: &str) -> RsmqResult; + fn delete_message( + &mut self, + qname: &str, + id: &str, + ) -> impl Future> + Send; /// Deletes the queue and all the messages on it - async fn delete_queue(&mut self, qname: &str) -> RsmqResult<()>; + fn delete_queue(&mut self, qname: &str) -> impl Future> + Send; /// Returns the queue attributes and statistics - async fn get_queue_attributes(&mut self, qname: &str) -> RsmqResult; + fn get_queue_attributes( + &mut self, + qname: &str, + ) -> impl Future> + Send; /// Returns a list of queues in the namespace - async fn list_queues(&mut self) -> RsmqResult>; + fn list_queues(&mut self) -> impl Future>> + Send; /// Deletes and returns a message. Be aware that using this you may end with deleted & unprocessed messages. - async fn pop_message>>( + fn pop_message>>( &mut self, qname: &str, - ) -> RsmqResult>>; + ) -> impl Future>>> + Send; /// Returns a message. The message stays hidden for some time (defined by "hidden" argument or the queue /// settings). After that time, the message will be redelivered. In order to avoid the redelivery, you need to use /// the "delete_message" after this function. /// /// `hidden` has a max time of 9_999_999 for compatibility reasons to this library JS version counterpart. - async fn receive_message>>( + fn receive_message>>( &mut self, qname: &str, hidden: Option, - ) -> RsmqResult>>; + ) -> impl Future>>> + Send; /// Sends a message to the queue. The message will be delayed some time (controlled by the "delayed" argument or /// the queue settings) before being delivered to a client. - async fn send_message + Send>( + fn send_message + Send>( &mut self, qname: &str, message: E, delay: Option, - ) -> RsmqResult; + ) -> impl Future> + Send; /// Modify the queue attributes. Keep in mind that "hidden" and "delay" can be overwritten when the message /// is sent. "hidden" can be changed by the method "change_message_visibility" @@ -83,11 +90,11 @@ pub trait RsmqConnection { /// /// maxsize: Maximum size in bytes of each message in the queue. Needs to be between 1024 or 65536 or -1 (unlimited /// size) - async fn set_queue_attributes( + fn set_queue_attributes( &mut self, qname: &str, hidden: Option, delay: Option, maxsize: Option, - ) -> RsmqResult; + ) -> impl Future> + Send; } diff --git a/tests/support/mod.rs b/tests/support/mod.rs index 3848741..08984b3 100644 --- a/tests/support/mod.rs +++ b/tests/support/mod.rs @@ -113,7 +113,7 @@ impl TestContext { } } } - redis::cmd("FLUSHDB").execute(&mut con); + let _ = redis::cmd("FLUSHDB").exec(&mut con); TestContext { server, client } }