Skip to content

Upgrade dependencies #29

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 4 additions & 5 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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]
Expand Down
2 changes: 1 addition & 1 deletion src/functions.rs
Original file line number Diff line number Diff line change
Expand Up @@ -586,7 +586,7 @@ impl<T: ConnectionLike> RsmqFunctions<T> {
fn make_id(len: usize) -> RsmqResult<String> {
let possible = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789";

let mut rng = rand::thread_rng();
let mut rng = rand::rng();

let mut id = String::with_capacity(len);

Expand Down
1 change: 0 additions & 1 deletion src/multiplexed_facade.rs
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,6 @@ impl Rsmq {
}
}

#[async_trait::async_trait]
impl RsmqConnection for Rsmq {
async fn change_message_visibility(
&mut self,
Expand Down
3 changes: 0 additions & 3 deletions src/pooled_facade.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -20,7 +19,6 @@ impl RedisConnectionManager {
}
}

#[async_trait]
impl bb8::ManageConnection for RedisConnectionManager {
type Connection = redis::aio::MultiplexedConnection;
type Error = RedisError;
Expand Down Expand Up @@ -142,7 +140,6 @@ impl PooledRsmq {
}
}

#[async_trait::async_trait]
impl RsmqConnection for PooledRsmq {
async fn change_message_visibility(
&mut self,
Expand Down
1 change: 0 additions & 1 deletion src/sync_facade.rs
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,6 @@ impl RsmqSync {
}
}

#[async_trait::async_trait]
impl RsmqConnection for RsmqSync {
async fn change_message_visibility(
&mut self,
Expand Down
41 changes: 24 additions & 17 deletions src/trait.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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<Output = RsmqResult<()>> + Send;

/// Creates a new queue. Attributes can be later modified with "set_queue_attributes" method
///
Expand All @@ -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<Duration>,
delay: Option<Duration>,
maxsize: Option<i32>,
) -> RsmqResult<()>;
) -> impl Future<Output = RsmqResult<()>> + 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<bool>;
fn delete_message(
&mut self,
qname: &str,
id: &str,
) -> impl Future<Output = RsmqResult<bool>> + 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<Output = RsmqResult<()>> + Send;

/// Returns the queue attributes and statistics
async fn get_queue_attributes(&mut self, qname: &str) -> RsmqResult<RsmqQueueAttributes>;
fn get_queue_attributes(
&mut self,
qname: &str,
) -> impl Future<Output = RsmqResult<RsmqQueueAttributes>> + Send;

/// Returns a list of queues in the namespace
async fn list_queues(&mut self) -> RsmqResult<Vec<String>>;
fn list_queues(&mut self) -> impl Future<Output = RsmqResult<Vec<String>>> + Send;

/// Deletes and returns a message. Be aware that using this you may end with deleted & unprocessed messages.
async fn pop_message<E: TryFrom<RedisBytes, Error = Vec<u8>>>(
fn pop_message<E: TryFrom<RedisBytes, Error = Vec<u8>>>(
&mut self,
qname: &str,
) -> RsmqResult<Option<RsmqMessage<E>>>;
) -> impl Future<Output = RsmqResult<Option<RsmqMessage<E>>>> + 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<E: TryFrom<RedisBytes, Error = Vec<u8>>>(
fn receive_message<E: TryFrom<RedisBytes, Error = Vec<u8>>>(
&mut self,
qname: &str,
hidden: Option<Duration>,
) -> RsmqResult<Option<RsmqMessage<E>>>;
) -> impl Future<Output = RsmqResult<Option<RsmqMessage<E>>>> + 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<E: Into<RedisBytes> + Send>(
fn send_message<E: Into<RedisBytes> + Send>(
&mut self,
qname: &str,
message: E,
delay: Option<Duration>,
) -> RsmqResult<String>;
) -> impl Future<Output = RsmqResult<String>> + 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"
Expand All @@ -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<Duration>,
delay: Option<Duration>,
maxsize: Option<i64>,
) -> RsmqResult<RsmqQueueAttributes>;
) -> impl Future<Output = RsmqResult<RsmqQueueAttributes>> + Send;
}
2 changes: 1 addition & 1 deletion tests/support/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,7 @@ impl TestContext {
}
}
}
redis::cmd("FLUSHDB").execute(&mut con);
let _ = redis::cmd("FLUSHDB").exec(&mut con);

TestContext { server, client }
}
Expand Down
Loading