Skip to content

Commit

Permalink
Improve callback docs
Browse files Browse the repository at this point in the history
Signed-off-by: Tomasz Pietrek <[email protected]>
  • Loading branch information
Jarema authored Aug 6, 2022
1 parent 1e2187b commit ad608d3
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 2 deletions.
4 changes: 4 additions & 0 deletions async-nats/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,16 @@
## Overview
This release focuses on fixes and improvements, with addition of ordered Push Consumer.

## Breaking Changes
* Refactor callbacks by @Jarema in https://github.com/nats-io/nats.rs/pull/595

## Added
* Add `get_last_raw_message_by_subject` to `Stream` by @caspervonb in https://github.com/nats-io/nats.rs/pull/584
* Add `ClusterInfo` and `PeerInfo` by @Jarema in https://github.com/nats-io/nats.rs/pull/572
* Add ordered push consumer by @Jarema in https://github.com/nats-io/nats.rs/pull/574
* Add concurrent example by @Jarema in https://github.com/nats-io/nats.rs/pull/580
* Add delete message from stream by @Jarema in https://github.com/nats-io/nats.rs/pull/588
* Add Nkey authorization support by @neogenie https://github.com/nats-io/nats.rs/pull/593

## Fixed
* Fix ordered consumer after discard policy hit by @Jarema in https://github.com/nats-io/nats.rs/pull/585
Expand Down
22 changes: 20 additions & 2 deletions async-nats/src/options.rs
Original file line number Diff line number Diff line change
Expand Up @@ -406,11 +406,29 @@ impl ConnectOptions {
///
/// ## Basic
/// If you don't need to move anything into the closure, simple signature can be used:
///
/// ```no_run
/// # #[tokio::main]
/// # async fn main() -> std::io::Result<()> {
/// async_nats::ConnectOptions::new().event_callback(|event| async move {
/// println!("event occured: {}", event);
/// println!("event occured: {}", event);
/// }).connect("demo.nats.io").await?;
/// # Ok(())
/// # }
///
/// ```
///
/// ## Listening to specific event kind
/// ```no_run
/// # #[tokio::main]
/// # async fn main() -> std::io::Result<()> {
/// async_nats::ConnectOptions::new().event_callback(|event| async move {
/// match event {
/// async_nats::Event::Disconnect => println!("disconnected"),
/// async_nats::Event::Reconnect => println!("reconnected"),
/// async_nats::Event::ClientError(err) => println!("client error occured: {}", err),
/// other => println!("other event happened: {}", other),
/// }
/// }).connect("demo.nats.io").await?;
/// # Ok(())
/// # }
Expand All @@ -419,7 +437,7 @@ impl ConnectOptions {
/// ## Advanced
/// If you need to move something into the closure, here's an example how to do that
///
/// ```
/// ```no_run
/// # #[tokio::main]
/// # async fn main() -> std::result::Result<(), Box<dyn std::error::Error>> {
/// let (tx, mut _rx) = tokio::sync::mpsc::channel(1);
Expand Down

0 comments on commit ad608d3

Please sign in to comment.