Skip to content

Commit cd835d9

Browse files
committed
Update redis version to 0.27
1 parent ba14653 commit cd835d9

File tree

8 files changed

+37
-14
lines changed

8 files changed

+37
-14
lines changed

Cargo.toml

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,7 @@
11
[package]
22
name = "rsmq_async"
3-
version = "12.0.0"
4-
authors = [
5-
"David Bonet <webbonet@gmail.com>"
6-
]
3+
version = "13.0.0"
4+
authors = ["David Bonet <webbonet@gmail.com>"]
75
edition = "2021"
86
license = "MIT"
97
description = "Async 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"
@@ -18,13 +16,17 @@ rand = "^0.8"
1816
radix_fmt = "^1"
1917
bb8 = "^0.8"
2018
thiserror = "^1"
21-
redis = { version = "^0.25", default-features = false, features = ["acl", "keep-alive", "script"] }
19+
redis = { version = "^0.27", default-features = false, features = [
20+
"acl",
21+
"keep-alive",
22+
"script",
23+
] }
2224
async-trait = "^0.1"
23-
tokio = { version = "^1", optional = true}
25+
tokio = { version = "^1", optional = true }
2426

2527
[dev-dependencies]
2628
net2 = "^0.2"
27-
tokio = { version = "^1", features = ["rt-multi-thread"]}
29+
tokio = { version = "^1", features = ["rt-multi-thread"] }
2830

2931
[features]
3032
default = ["tokio-comp", "sync"]

src/functions.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -117,7 +117,7 @@ impl<T: ConnectionLike> RsmqFunctions<T> {
117117
number_in_range(hidden, 0, JS_COMPAT_MAX_TIME_MILLIS)?;
118118

119119
cached_script
120-
.invoke_change_message_visibility::<_, T>(
120+
.invoke_change_message_visibility::<(), T>(
121121
conn,
122122
format!("{}:{}", self.ns, qname),
123123
message_id.to_string(),
@@ -205,7 +205,7 @@ impl<T: ConnectionLike> RsmqFunctions<T> {
205205
redis::cmd("SADD")
206206
.arg(format!("{}:QUEUES", self.ns))
207207
.arg(qname)
208-
.query_async::<_, ()>(conn)
208+
.query_async::<()>(conn)
209209
.await?;
210210

211211
Ok(())
@@ -463,7 +463,7 @@ impl<T: ConnectionLike> RsmqFunctions<T> {
463463
redis::cmd("PUBLISH")
464464
.arg(format!("{}:rt:{}", self.ns, qname))
465465
.arg(result[3])
466-
.query_async::<_, ()>(conn)
466+
.query_async::<()>(conn)
467467
.await?;
468468
}
469469

@@ -534,7 +534,7 @@ impl<T: ConnectionLike> RsmqFunctions<T> {
534534
.arg(maxsize);
535535
}
536536

537-
commands.query_async::<_, ()>(conn).await?;
537+
commands.query_async::<()>(conn).await?;
538538

539539
self.get_queue_attributes(conn, qname).await
540540
}

src/multiplexed_facade.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@ impl Rsmq {
3131
db: options.db.into(),
3232
username: options.username,
3333
password: options.password,
34+
protocol: options.protocol,
3435
},
3536
};
3637

src/pooled_facade.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,7 @@ impl PooledRsmq {
7575
db: options.db.into(),
7676
username: options.username,
7777
password: options.password,
78+
protocol: options.protocol,
7879
},
7980
};
8081

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,19 @@
1-
local msg = redis.call("ZSCORE", KEYS[1], KEYS[2])
2-
if not msg then
1+
-- changeMessageVisibility.lua
2+
-- This script changes the visibility timestamp of a message in a Redis sorted set.
3+
-- KEYS[1]: The Redis key for the sorted set representing the message queue.
4+
-- KEYS[2]: The message ID whose visibility is to be updated.
5+
-- KEYS[3]: The new visibility timestamp to be set for the message.
6+
7+
-- Retrieve the current score (visibility timestamp) of the message
8+
local currentScore = redis.call("ZSCORE", KEYS[1], KEYS[2])
9+
10+
-- If the message does not exist in the sorted set, return false
11+
if not currentScore then
312
return false
413
end
14+
15+
-- Update the message's visibility timestamp (score) to the new value provided
516
redis.call("ZADD", KEYS[1], KEYS[3], KEYS[2])
17+
18+
-- Return true indicating that the visibility has been successfully updated
619
return true

src/sync_facade.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@ impl RsmqSync {
3939
db: options.db.into(),
4040
username: options.username,
4141
password: options.password,
42+
protocol: options.protocol,
4243
},
4344
};
4445

src/types.rs

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
use redis::ProtocolVersion;
12
use std::{convert::TryFrom, time::Duration};
23

34
#[derive(Debug)]
@@ -27,6 +28,8 @@ pub struct RsmqOptions {
2728
pub password: Option<String>,
2829
/// RSMQ namespace (you can have several. "rsmq" by default)
2930
pub ns: String,
31+
/// Redisa protocol. Defaults to RESP2
32+
pub protocol: ProtocolVersion,
3033
}
3134

3235
impl Default for RsmqOptions {
@@ -39,6 +42,7 @@ impl Default for RsmqOptions {
3942
username: None,
4043
password: None,
4144
ns: "rsmq".to_string(),
45+
protocol: ProtocolVersion::RESP2,
4246
}
4347
}
4448
}
@@ -99,7 +103,7 @@ pub struct RsmqQueueAttributes {
99103
/// ```rust,ignore
100104
/// use std::convert::TryFrom;
101105
/// use rsmq_async::RedisBytes;
102-
///
106+
///
103107
/// impl TryFrom<RedisBytes> for String {
104108
/// type Error = Vec<u8>;
105109
///

tests/support/mod.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -91,6 +91,7 @@ impl TestContext {
9191
db: 0,
9292
username: None,
9393
password: None,
94+
..Default::default()
9495
},
9596
})
9697
.unwrap();

0 commit comments

Comments
 (0)