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

Refactor connection handling #1060

Merged
merged 12 commits into from
Sep 19, 2023
4 changes: 2 additions & 2 deletions 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.28", default-features = false, features = ["std", "async-await"] }
futures = { version = "0.3.28", default-features = false, features = ["std"] }
nkeys = "0.3.1"
once_cell = "1.18.0"
regex = "1.9.1"
Expand All @@ -25,7 +25,6 @@ serde_json = "1.0.104"
serde_repr = "0.1.16"
http = "0.2.9"
tokio = { version = "1.29.0", features = ["macros", "rt", "fs", "net", "sync", "time", "io-util"] }
itoa = "1"
url = { version = "2"}
tokio-rustls = "0.24"
rustls-pemfile = "1.0.2"
Expand All @@ -49,6 +48,7 @@ criterion = { version = "0.5", features = ["async_tokio"]}
nats-server = { path = "../nats-server" }
rand = "0.8"
tokio = { version = "1.25.0", features = ["rt-multi-thread"] }
futures = { version = "0.3.28", default-features = false, features = ["std", "async-await"] }
tracing-subscriber = "0.3"
async-nats = {path = ".", features = ["experimental"]}
reqwest = "0.11.18"
Expand Down
8 changes: 2 additions & 6 deletions async-nats/src/client.rs
Original file line number Diff line number Diff line change
Expand Up @@ -346,9 +346,6 @@ impl Client {
}
None => self.publish_with_reply(subject, inbox, payload).await?,
}
self.flush()
.await
.map_err(|err| RequestError::with_source(RequestErrorKind::Other, err))?;
let request = match timeout {
Some(timeout) => {
tokio::time::timeout(timeout, sub.next())
Expand Down Expand Up @@ -517,12 +514,11 @@ impl Client {
pub async fn flush(&self) -> Result<(), FlushError> {
let (tx, rx) = tokio::sync::oneshot::channel();
self.sender
.send(Command::Flush { result: tx })
.send(Command::Flush { observer: tx })
.await
.map_err(|err| FlushError::with_source(FlushErrorKind::SendError, err))?;
// first question mark is an error from rx itself, second for error from flush.

rx.await
.map_err(|err| FlushError::with_source(FlushErrorKind::FlushError, err))?
.map_err(|err| FlushError::with_source(FlushErrorKind::FlushError, err))?;
Ok(())
}
Expand Down
Loading
Loading