Settings¶
Settings¶
nats.Core takes a Settings. nats.JetStream takes a JetStreamSettings, which embeds it.
| Field | Type | Default | What it does |
|---|---|---|---|
Client |
gonats.ClientSettings |
zero value, then go/nats's defaults | The connection. See Client settings. |
Credentials |
gonats.CredentialSource |
nil |
Yields the token the connection authenticates with. |
Options |
[]client.Option |
none | go/nats client options. client.InProcess(server) connects to an embedded server. |
Logger |
*slog.Logger |
discards everything | Receives the adapter's own log lines and is passed to the client with client.WithLogger. |
Format |
envelope.Format |
CloudEvents binary for the NATS binding | Writes every event, request and reply this backend sends. |
Reads |
[]envelope.Format |
CloudEvents binary for the NATS binding, then CloudEvents structured | The chain a received message is read with. Exactly one format must claim a message. |
A nil Logger is replaced with slog.DiscardHandler by both constructors, so the warnings that
find unreadable messages depends on are silent until you set one.
An empty Reads takes the default chain. A Reads you set replaces the default chain; it does not
extend it. See Choose a wire format.
Source: Settings in core.go; the defaults are codecOf in format.go.
JetStreamSettings¶
| Field | Type | Default | What it does |
|---|---|---|---|
Settings |
Settings |
see above | Embedded; one set of fields serves both backends. |
Stream |
string |
none | The operator's stream, which must exist and be file-backed. |
Open fails with ErrNoStream when the stream does not exist and with
ErrMemoryStream when it is memory-backed.
Source: JetStreamSettings and (*jetStream).Open in jetstream.go.
Client settings¶
Client, Credentials and Options are go/nats's,
unchanged; this adapter pins go/nats v0.2.4. The defaults below are that version's, from
settings.go.
ClientSettings field |
Default | Notes |
|---|---|---|
URL |
none | Empty is valid only with client.InProcess. |
Name |
none | Names the connection in the server's monitoring. Worth setting. |
MaxReconnects |
nil, which means retry for ever |
A *int; build one with gonats.Reconnects(n). A pointer so that 0 can mean "do not reconnect". |
ReconnectWait |
2 seconds | Pause between attempts. |
PendingMsgs |
4096 | Bounds every subscription the client makes. |
PendingBytes |
32 MiB | The same bound, in bytes. |
go/nats documents a nil Credentials as valid only for an in-process server with no authentication.
PendingMsgs is the client-wide bound. A core subscription then sets its own pending limit to the
subscription's Bound, with PendingBytes as the byte limit. See
Core NATS or JetStream.
Subscription fields the adapter reads¶
These are the core's SubscriptionSpec fields, passed to the adapter as a SourceSpec. What each
means in general is in the backend contract.
| Field | Core | JetStream, AtMostOnce |
JetStream, AtLeastOnce |
|---|---|---|---|
Pattern |
the NATS subscription subject | as Core | the consumer's FilterSubject |
Shape |
Fanout is Subscribe; Competing is QueueSubscribe on Group |
as Core | not read; see Subscribe durably |
Bound |
the subscription's pending message limit | as Core | the pull batch (PullMaxMessages), except 1 under ExtendLease |
Overflow |
OverflowNative or ShedNewest; anything else is ErrNotSupported |
as Core | the core refuses ShedNewest and ShedOldest before the adapter sees them |
Mode |
AtLeastOnce is ErrNotSupported |
selects the core path | selects the durable consumer |
DurableName |
refused by the core | refused by the core | the consumer's name and durable name |
StartAt |
refused by the core | refused by the core | NewMessages is DeliverNew; AllAvailable is DeliverAll |
MaxDeliver |
refused by the core | refused by the core | the consumer's MaxDeliver |
AckWait |
refused by the core | refused by the core | the consumer's AckWait; zero takes the server's default, 30 seconds |
SlowHandler, MaxProcessingTime |
refused by the core | refused by the core | ExtendLease heartbeats with InProgress; Redeliver does not |
Backoff, NackAfter |
refused by the core | refused by the core | a decline's delay is sent as NakWithDelay |
Source: (*session).Subscribe in session.go; (*jetSession).Subscribe and consumerConfig in
jetsession.go; newJetSource in jetsource.go; the core's validateAtLeastOnce and
validateAtMostOnce in bus.go.