From e2c52acbd8cf3eda0b2ea3d6dfb3214a73c87143 Mon Sep 17 00:00:00 2001 From: HeCorr Date: Sun, 19 May 2024 04:15:27 -0300 Subject: [PATCH 1/3] add client.flush() calls to example code see https://github.com/nats-io/nats.rs/issues/773#issuecomment-2119116600 --- async-nats/src/lib.rs | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/async-nats/src/lib.rs b/async-nats/src/lib.rs index 34cf05136..d939a8435 100755 --- a/async-nats/src/lib.rs +++ b/async-nats/src/lib.rs @@ -54,6 +54,9 @@ //! client.publish("messages", "data".into()).await?; //! } //! +//! // Flush internal buffer to make sure messages are sent +//! client.flush().await?; +//! //! // Receive and process messages //! while let Some(message) = subscriber.next().await { //! println!("Received message {:?}", message); @@ -84,6 +87,10 @@ //! for _ in 0..10 { //! client.publish(subject, data.clone()).await?; //! } +//! +//! // Flush internal buffer to make sure messages are sent +//! client.flush().await?; +//! //! # Ok(()) //! # } //! ``` From a61a59a92ef054e762e43c6d5f673cd3abaf8fc9 Mon Sep 17 00:00:00 2001 From: HeCorr Date: Sun, 19 May 2024 15:08:58 -0300 Subject: [PATCH 2/3] fix flush() comment formatting to make CI happy --- async-nats/src/lib.rs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/async-nats/src/lib.rs b/async-nats/src/lib.rs index d939a8435..fa3cadadf 100755 --- a/async-nats/src/lib.rs +++ b/async-nats/src/lib.rs @@ -87,10 +87,10 @@ //! for _ in 0..10 { //! client.publish(subject, data.clone()).await?; //! } -//! +//! //! // Flush internal buffer to make sure messages are sent //! client.flush().await?; -//! +//! //! # Ok(()) //! # } //! ``` From 5be6e7cda639cf9873a9db55e95f54b562c4c5ed Mon Sep 17 00:00:00 2001 From: HeCorr Date: Sun, 19 May 2024 16:06:50 -0300 Subject: [PATCH 3/3] change flush() comments on example code - remove flush() call from complete example code - change phrasing on publish-only example comment --- async-nats/src/lib.rs | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/async-nats/src/lib.rs b/async-nats/src/lib.rs index fa3cadadf..f6e20a527 100755 --- a/async-nats/src/lib.rs +++ b/async-nats/src/lib.rs @@ -54,9 +54,6 @@ //! client.publish("messages", "data".into()).await?; //! } //! -//! // Flush internal buffer to make sure messages are sent -//! client.flush().await?; -//! //! // Receive and process messages //! while let Some(message) = subscriber.next().await { //! println!("Received message {:?}", message); @@ -88,7 +85,7 @@ //! client.publish(subject, data.clone()).await?; //! } //! -//! // Flush internal buffer to make sure messages are sent +//! // Flush internal buffer before exiting to make sure all messages are sent //! client.flush().await?; //! //! # Ok(())