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

add reconnect_buffer_size builder fn #1249

Closed
wants to merge 1 commit into from
Closed
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
22 changes: 22 additions & 0 deletions async-nats/src/options.rs
Original file line number Diff line number Diff line change
Expand Up @@ -854,6 +854,28 @@ impl ConnectOptions {
self
}


/// Sets the number of bytes that can be cached if the connection to the NATS server is lost.
/// The publisher can still receive messages and will publish those once reconnected.
/// When the maximum reconnect buffer is reached, messages will no longer be received
/// by the publisher and an error will be returned.
///
/// # Examples
/// ```
/// # #[tokio::main]
/// # async fn main() -> std::result::Result<(), Box<dyn std::error::Error>> {
/// async_nats::ConnectOptions::new()
/// .reconnect_buffer_size(8 * 1024 * 1024) // 8mb
/// .connect("demo.nats.io")
/// .await?;
/// # Ok(())
/// # }
/// ```
pub fn reconnect_buffer_size(mut self, size: usize) -> ConnectOptions {
self.reconnect_buffer_size = size;
self
}

/// By default, a server may advertise other servers in the cluster known to it.
/// By setting this option, the client will ignore the advertised servers.
/// This may be useful if the client may not be able to reach them.
Expand Down