Перейти к основному содержимому
Эта страница ещё не переведена

Ниже показан английский оригинал.

Server

The server reports the host and port of each configured address, never credentials; the protocol version is read once connected.

A broker registered with with_broker_labeled is a server of the document, under its label. Its host is the host and port of every address NatsBroker::new took, joined with commas. The scheme and any user, password or token an address carries stay out of it. The protocol is nats.

The credentials and TLS settings of the connect options never reach the document either. The version of the NATS client protocol is a fact of the live connection, and the document is built before anything dials, so protocolVersion stays out. ConnectedNatsBroker::server_spec reports it once connected, with the host and port the server announced.

Example​

The broker reaches two servers with a password in each address. Its server in the document is nats-1.internal:4222,nats-2.internal:4222.

/// The cluster, logged in with the user and password the URLs carry.
fn broker(password: &str) -> NatsBroker {
NatsBroker::new(format!(
"nats://orders-svc:{password}@nats-1.internal:4222,\
nats://orders-svc:{password}@nats-2.internal:4222"
))
}