pub struct NatsConfigBuilder { /* private fields */ }
Expand description

Builder for NatsConfig.

Implementations§

source§

impl NatsConfigBuilder

source

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.

source

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

source

pub fn name<VALUE: Into<Option<String>>>(&mut self, value: VALUE) -> &mut Self

source

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.

source

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.

source

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.

source

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

source

pub fn build(&self) -> Result<NatsConfig, NatsConfigBuilderError>

Builds a new NatsConfig.

Errors

If a required field has not been initialized.

Trait Implementations§

source§

impl Clone for NatsConfigBuilder

source§

fn clone(&self) -> NatsConfigBuilder

Returns a copy of the value. Read more
1.0.0 · source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
source§

impl Default for NatsConfigBuilder

source§

fn default() -> Self

Returns the “default value” for a type. Read more

Auto Trait Implementations§

Blanket Implementations§

source§

impl<T> Any for Twhere T: 'static + ?Sized,

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

impl<T> Borrow<T> for Twhere T: ?Sized,

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for Twhere T: ?Sized,

source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
source§

impl<T> From<T> for T

source§

fn from(t: T) -> T

Returns the argument unchanged.

source§

impl<T> Instrument for T

source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
source§

impl<T, U> Into<U> for Twhere U: From<T>,

source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

source§

impl<T> ToOwned for Twhere T: Clone,

§

type Owned = T

The resulting type after obtaining ownership.
source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
source§

impl<T, U> TryFrom<U> for Twhere U: Into<T>,

§

type Error = Infallible

The type returned in the event of a conversion error.
source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
source§

impl<T, U> TryInto<U> for Twhere U: TryFrom<T>,

§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
source§

impl<T> WithSubscriber for T

source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more