Skip to content
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

Reduce usage of the futures crate #935

Closed
wants to merge 2 commits 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
2 changes: 1 addition & 1 deletion async-nats/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ categories = ["network-programming", "api-bindings"]
[dependencies]
memchr = "2.4"
bytes = { version = "1.4.0", features = ["serde"] }
futures = { version = "0.3.26", default-features = false, features = ["std", "async-await"] }
futures = { version = "0.3.26", default-features = false, features = ["alloc"] }
nkeys = "0.3.0"
once_cell = "1.17.1"
regex = "1.7.1"
Expand Down
2 changes: 1 addition & 1 deletion async-nats/examples/multiple_subs.rs
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ async fn main() -> Result<(), async_nats::Error> {
});

// run both publishing tasks in parallel and gather the results.
match futures::try_join!(foo_pub_handle, bar_pub_handle) {
match tokio::try_join!(foo_pub_handle, bar_pub_handle) {
Ok((foo_duration, bar_duration)) => println!(
"finished publishing foo in {:?} and bar in {:?}",
foo_duration?, bar_duration?
Expand Down
11 changes: 5 additions & 6 deletions async-nats/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -121,9 +121,8 @@

use thiserror::Error;

use futures::future::FutureExt;
use futures::select;
use futures::stream::Stream;
use tokio::select;
use tracing::{debug, error};

use core::fmt;
Expand Down Expand Up @@ -356,7 +355,7 @@ impl ConnectionHandler {
) -> Result<(), io::Error> {
loop {
select! {
_ = self.ping_interval.tick().fuse() => {
_ = self.ping_interval.tick() => {
self.pending_pings += 1;

if self.pending_pings > MAX_PENDING_PINGS {
Expand All @@ -374,12 +373,12 @@ impl ConnectionHandler {
self.handle_flush().await?;

},
_ = self.flush_interval.tick().fuse() => {
_ = self.flush_interval.tick() => {
if let Err(_err) = self.handle_flush().await {
self.handle_disconnect().await?;
}
},
maybe_command = receiver.recv().fuse() => {
maybe_command = receiver.recv() => {
match maybe_command {
Some(command) => if let Err(err) = self.handle_command(command).await {
error!("error handling command {}", err);
Expand All @@ -390,7 +389,7 @@ impl ConnectionHandler {
}
}

maybe_op_result = self.connection.read_op().fuse() => {
maybe_op_result = self.connection.read_op() => {
match maybe_op_result {
Ok(Some(server_op)) => if let Err(err) = self.handle_server_op(server_op).await {
error!("error handling operation {}", err);
Expand Down