Struct tokio_nats::NatsConfigBuilder
source · pub struct NatsConfigBuilder { /* private fields */ }
Expand description
Builder for NatsConfig
.
Implementations§
source§impl NatsConfigBuilder
impl NatsConfigBuilder
sourcepub fn buffer_size<VALUE: Into<usize>>(&mut self, value: VALUE) -> &mut Self
pub fn buffer_size<VALUE: Into<usize>>(&mut self, value: VALUE) -> &mut Self
The size of the queues used to both send and receive messages. Using a buffer too small will
make publish
block until there is capacity to add a new message to the send queue. It will
also make subscriptions miss messages in the event of a slow consumer.
sourcepub fn server<VALUE: Into<String>>(&mut self, value: VALUE) -> &mut Self
pub fn server<VALUE: Into<String>>(&mut self, value: VALUE) -> &mut Self
The host and port of the NATS server to connect to. E.g. 127.0.0.1:4222
pub fn name<VALUE: Into<Option<String>>>(&mut self, value: VALUE) -> &mut Self
sourcepub fn ping_period<VALUE: Into<Duration>>(&mut self, value: VALUE) -> &mut Self
pub fn ping_period<VALUE: Into<Duration>>(&mut self, value: VALUE) -> &mut Self
How often should the client send PING
messages to the server to confirm that the connection
is alive.
Default 5 seconds.
sourcepub fn reconnection_period<VALUE: Into<Duration>>(
&mut self,
value: VALUE
) -> &mut Self
pub fn reconnection_period<VALUE: Into<Duration>>( &mut self, value: VALUE ) -> &mut Self
How long should the the client wait between reconnection attempts if the connection fails.
Default 1 second.
sourcepub fn connection_timeout<VALUE: Into<Duration>>(
&mut self,
value: VALUE
) -> &mut Self
pub fn connection_timeout<VALUE: Into<Duration>>( &mut self, value: VALUE ) -> &mut Self
How long should the client wait while trying to establish a connection to the server.
Default 5 seconds.
sourcepub fn tls_params<VALUE: Into<Option<TlsConnParams>>>(
&mut self,
value: VALUE
) -> &mut Self
pub fn tls_params<VALUE: Into<Option<TlsConnParams>>>( &mut self, value: VALUE ) -> &mut Self
TLS Parameter must be built with contents in PEM format from CA Certificates, client certificates and client key This is Mandatory to enable TLS connection e.g.
let key_location = "client_key_location.pem";
let cert_location = "client_cert_location.pem";
let ca_location = "ca_cert_location.pem";
let mut build = TLSConnBuild::new();
let cert_file = File::open(cert_location).expect("cannot open private cert file");
let mut reader = BufReader::new(cert_file);
build
.client_certs(&mut reader)
.expect("Unable to handle client certs");
let key_file = File::open(key_location).expect("Cannot open private key file");
let mut reader = BufReader::new(key_file);
build
.client_key(&mut reader)
.expect("Unable to handle client key");
let ca_file = File::open(ca_location).expect("Cannot open CA cert file");
let mut reader = BufReader::new(ca_file);
build
.root_cert(&mut reader)
.expect("Unable to load CA cert");
let tls_param = build.build().expect("Unable to build TLS Parameters");
Default: None
sourcepub fn build(&self) -> Result<NatsConfig, NatsConfigBuilderError>
pub fn build(&self) -> Result<NatsConfig, NatsConfigBuilderError>
Trait Implementations§
source§impl Clone for NatsConfigBuilder
impl Clone for NatsConfigBuilder
source§fn clone(&self) -> NatsConfigBuilder
fn clone(&self) -> NatsConfigBuilder
1.0.0 · source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source
. Read more