options
ModuleHow a crate::Connection connects and behaves.
Contents
Type aliases
ErrorHookReceives the errors the server reports (`on_error`).HookA notification without arguments (`on_disconnect`, `on_reconnect`, `on_close`, `on_lame_duck`).ProviderProduces a credential at every (re)connect (`token_provider`, `jwt_provider`).SlowConsumerHookReceives a subscription that dropped messages over its pending limits.TransportFactoryBuilds the transport for a URL scheme (`nats`, `tls`, `ws`, `wss`).use utopia_nats::ConnectionOptions;Rust
pub struct ConnectionOptionsServers, credentials, TLS, reconnection, limits, timeouts and callbacks.
Build one with ConnectionOptions::new and set the fields that
differ from the defaults
Rust
use std::time::Duration;
use utopia_nats::ConnectionOptions;
let options = ConnectionOptions {
name: "billing".into(),
request_timeout: Duration::from_secs(2),
..ConnectionOptions::new(["nats://10.0.0.1:4222", "nats://10.0.0.2:4222"])
};
assert_eq!(options.servers.len(), 2);
assert!(options.allow_reconnect);Also implements
Default, From, Debug.Rust
pub type ErrorHook = Arc<dyn Fn(&Error) -> Result<(), CallbackError> + Send + Sync>Receives the errors the server reports (on_error).
Rust
pub type Hook = Arc<dyn Fn() -> Result<(), CallbackError> + Send + Sync>A notification without arguments (on_disconnect, on_reconnect,
on_close, on_lame_duck).
Rust
pub type Provider = Arc<dyn Fn() -> Result<String, CallbackError> + Send + Sync>Produces a credential at every (re)connect (token_provider,
jwt_provider).
Rust
pub type SlowConsumerHook = Arc<dyn Fn(&SubscriptionState) -> Result<(), CallbackError> + Send + Sync>Receives a subscription that dropped messages over its pending limits.
Rust
pub type TransportFactory = Arc<dyn Fn(&str) -> Result<Box<dyn Transport>, CallbackError> + Send + Sync>Builds the transport for a URL scheme (nats, tls, ws, wss).