connect_nats

Function connect_nats 

Source
pub async fn connect_nats(
    addr: impl ToServerAddrs,
    jwt: Option<&String>,
    key: Option<Arc<KeyPair>>,
    require_tls: bool,
    request_timeout: Option<Duration>,
    workload_identity_config: Option<WorkloadIdentityConfig>,
) -> Result<Client>
Expand description

Given the NATS address, authentication jwt, seed, tls requirement and optional request timeout, attempt to establish connection.

This function should be used to create a NATS client for Host communication, for non-host NATS clients we recommend using async-nats directly.

ยงErrors

Returns an error if:

  • Only one of JWT or seed is specified, as we cannot authenticate with only one of them
  • Connection fails