Skip to content

Commit 1f0df01

Browse files
committed
update redis to 0.16 for async_std compatibility
1 parent 7d57c3a commit 1f0df01

File tree

2 files changed

+52
-10
lines changed

2 files changed

+52
-10
lines changed

Cargo.toml

+4-4
Original file line numberDiff line numberDiff line change
@@ -11,10 +11,10 @@ documentation = "https://docs.rs/rsmq_async/"
1111
readme = "README.md"
1212

1313
[dependencies]
14-
redis = "0.15.1"
15-
lazy_static = "1.4.0"
16-
rand = "0.7.3"
17-
radix_fmt = "1.0.0"
14+
redis = "0.16"
15+
lazy_static = "1.4"
16+
rand = "0.7"
17+
radix_fmt = "1.0"
1818

1919
[dev-dependencies]
2020
net2 = "0.2.33"

src/lib.rs

+48-6
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
1-
//! This is a port of the nodejs Redis Simple Message Queue package. It is a 1-to-1 conversion using async.
1+
//! This is a port of the nodejs Redis Simple Message Queue package.
2+
//! It is a 1-to-1 conversion using async.
23
//!
34
//! ```rust,no_run
45
//! use rsmq_async::{Rsmq, RsmqError};
@@ -18,7 +19,10 @@
1819
//! Main object documentation in: <a href="struct.Rsmq.html">Rsmq<a/>
1920
//!
2021
//! ## Realtime
21-
//! When [initializing](#initialize) RSMQ you can enable the realtime PUBLISH for new messages. On every new message that gets sent to RSQM via `sendMessage` a Redis PUBLISH will be issued to `{rsmq.ns}:rt:{qname}`.
22+
//!
23+
//! When [initializing](#initialize) RSMQ you can enable the realtime PUBLISH for
24+
//! new messages. On every new message that gets sent to RSQM via `sendMessage` a
25+
//! Redis PUBLISH will be issued to `{rsmq.ns}:rt:{qname}`.
2226
//!
2327
//! Example for RSMQ with default settings:
2428
//!
@@ -27,15 +31,53 @@
2731
//! * The following Redis command will be issued: `PUBLISH rsmq:rt:testQueue 6`
2832
//!
2933
//! ### How to use the realtime option
30-
//! Besides the PUBLISH when a new message is sent to RSMQ nothing else will happen. Your app could use the Redis SUBSCRIBE command to be notified of new messages and issue a `receiveMessage` then. However make sure not to listen with multiple workers for new messages with SUBSCRIBE to prevent multiple simultaneous `receiveMessage` calls.
34+
//!
35+
//! Besides the PUBLISH when a new message is sent to RSMQ nothing else will happen.
36+
//! Your app could use the Redis SUBSCRIBE command to be notified of new messages
37+
//! and issue a `receiveMessage` then. However make sure not to listen with multiple
38+
//! workers for new messages with SUBSCRIBE to prevent multiple simultaneous
39+
//! `receiveMessage` calls.
3140
//!
3241
//! ## Guarantees
3342
//!
34-
//! If you want to implement "at least one delivery" guarantee, you need to receive the messages using "receive_message" and then, once the message is successfully processed, delete it with "delete_message".
43+
//! If you want to implement "at least one delivery" guarantee, you need to receive
44+
//! the messages using "receive_message" and then, once the message is successfully
45+
//! processed, delete it with "delete_message".
46+
//!
47+
//! ```rust,no_run
48+
//! use rsmq_async::Rsmq;
3549
//!
36-
//! If you want to implement "one or less delivery" guarantee, you can use the "pop_message" method. Be aware that you may loose (delete without processing) messages in that case.
50+
//! # #[tokio::main] //You can use Tokio or Async-std
51+
//! # async fn main() {
52+
//! let mut rsmq = Rsmq::new(Default::default())
53+
//! .await
54+
//! .expect("connection failed");
55+
//!
56+
//! rsmq.create_queue("myqueue", None, None, None)
57+
//! .await
58+
//! .expect("failed to create queue");
59+
//!
60+
//! rsmq.send_message("myqueue", "testmessage", None)
61+
//! .await
62+
//! .expect("failed to send message");
63+
//!
64+
//! let message = rsmq
65+
//! .receive_message("myqueue", None)
66+
//! .await
67+
//! .expect("cannot receive message");
68+
//!
69+
//! if let Some(message) = message {
70+
//! rsmq.delete_message("myqueue", &message.id).await;
71+
//! }
72+
//! # }
73+
//! ```
74+
//! ## Executor compatibility
75+
//!
76+
//! Since version 0.16 redis dependency supports tokio and async_std executors.
77+
//! By default it will guess what you are using when creating the connection.
78+
//! You can check [redis](https://github.com/mitsuhiko/redis-rs/blob/master/Cargo.toml)
79+
//! `Cargo.tolm` for the flags `async-std-comp` and `tokio-comp`
3780
//!
38-
3981
4082
#![forbid(unsafe_code)]
4183

0 commit comments

Comments
 (0)