ClientSettings¶
Constructs a connection. It does not carry the credential — see below.
| Field | Type | Default | Meaning |
|---|---|---|---|
URL |
string |
"" |
Server to reach. Empty only with client.InProcess |
Name |
string |
"" |
Connection name in the server's monitoring |
MaxReconnects |
int |
-1 |
Attempt limit. Negative is unlimited |
ReconnectWait |
time.Duration |
2s |
Pause between attempts |
PendingMsgs |
int |
4096 |
Per-subscription queue bound, in messages |
PendingBytes |
int |
32 MiB |
Per-subscription queue bound, in bytes |
The pending limits are the backpressure story¶
There is no other one. NATS sheds from a full subscription queue rather than delaying the publisher, and reports what it shed. A bound nobody set is a shed nobody sees.
The library's own default is 500,000 messages. This module's is two orders of magnitude smaller, so that shedding happens while the traffic causing it is still recent enough to explain.
Both bounds apply. Message count alone does not bound memory when payload size is not controlled.
See bound a subscription for how to surface the count.
MaxReconnects defaults to unlimited¶
Deliberately. A long-running service that stops trying to reconnect has to be restarted by a person to recover from a broker outage it would otherwise have survived unattended.
CredentialSource¶
A function rather than a string, so the secret is resolved at connect time rather than carried around, and so this module depends on no particular credential store.
The estate's ladder — an environment variable name, a keychain reference, a literal, then a
well-known variable — is composed by the calling application and handed in. That is the same shape
forge.CredentialSource takes, for the same reason: precedence is the consumer's decision, and a
library that decides it is a second statement of something the estate already states once.
StaticCredential(token) exists for tests and for a caller that resolved the secret by some route
this module has never heard of.
Passing nil is accepted and should only ever be done for an in-process server with no
authentication configured.