Golang client for NATS, the cloud native messaging system.
ConnectHandler
connect option to detect that initial connection was established. This is especially useful when combined with RetryOnFailedConnect
(#1133 )IgnoreAuthErrorAbort
connect option to prevent aborting reconnect attempts after receiving the same authentication error twice (#1141)SkipTLSHandshake
option to CustomDialer
. SkipTLSHandshake
method can be implemented on a custom dialer to prevent TLS handshake if not needed (#1147)ErrKeyExists
error when attempting to Create()
a KV pair for an existing key (#1135, #1136)ErrLeadershipChanged
error, returned when consumer leadership has changed during a pull request on a consumer. Thanks to @sata-form3 for the contribution (#1151)io/ioutil
. Thanks to @cesarvspr for the contribution (#1150)https://github.com/nats-io/nats.go/compare/v1.20.0...v1.21.0
nats: Consumer Deleted
server error to ErrConsumerDeleted
variable. This error is returned when consumer is deleted while waiting on pull request and was introduced in nats-server v2.9.6 (#1125)ErrConsumerNameAlreadyInUse
and StreamNameBySubject()
. Thanks to @subtle-byte for the contribution (#1128)RetryOnFailedConnect
connect option (#1127)https://github.com/nats-io/nats.go/compare/v1.19.1...v1.20.0
StreamNameBySubject
method on JetStreamContext
interface for looking up stream by subject (#1114)https://github.com/nats-io/nats.go/compare/v1.19.0...v1.19.1
InactiveThreshold
to align with server version 2.9.0. Thanks to @neilalexander for the contribution (#1106)https://github.com/nats-io/nats.go/compare/v1.18.0...v1.19.0
DiscardNewPerSubject
on stream configuration (#1102)KeyValueStores()
and KeyValueStoreNames()
methods for listing key value buckets (#1088)Bytes()
method on KeyValueStatus
returning size of the bucket (#1092)Subscribe()
method in JetStream
interface now has a better description of the behavior after unsubscribing from a durable consumer. Thanks to @sylr for the contribution (#1100)AckNone
policy can now be set for pull consumers (#1090)ObjectStores()
now returns channel of ObjectStoreStatus
instead of ObjectStore
interface (#1099)ObjectStore
methods now have individual types (GetObjectOpt
, GetObjectInfoOpt
and ListObjectsOpt
). Only options applicable for a particular method can be used (#1091)GetObjectInfoShowDeleted()
, GetObjectShowDeleted()
and ListObjectsShowDeleted()
(#1091)Tiers
field on AccountInfo
struct (#1095)https://github.com/nats-io/nats.go/compare/v1.17.0...v1.18.0
This release uses a new consumer create API when interacting with nats-server version 2.9.0 or higher. This changes the subjects used by the client to create consumers, which might in some cases require changes in access and import/export configuration. To opt out of this feature, use UseLegacyDurableConsumers()
option when creating JetStreamContext
.
JetStream:
PurgeStream()
now accepts StreamPurgeRequest
as an option, allowing partial purge by subject sequence number or keeping selected number of messages (#988)DeletedDetails
when fetching StreamInfo
. StreamInfo()
now accepts StreamInfoRequest
allowing to pass DeletedDetails
flag (#990)StreamInfo()
request. StreamInfo()
now accepts StreamInfoRequest
allowing to pass SubjectsFilter
value (#1010)AllowDirect
in stream configuration, enabling faster access to individual messages on a stream (#991)DirectGet
API in GetMsg()
through DirectGet()
and DirectGetNext()
options (#1020, #1030)HeadersOnly
option to RePublish
field on stream configuration and change struct name to RePublish
(#991)SecureDeleteMsg()
method to securely delete and overwrite a message on a stream (#1025)MaxRequestMaxBytes()
PullConsumer()
option allowing setting the maximum number of bytes a single Fetch()
can receive (#1043)StreamsInfo()
and StreamNames()
using StreamListFilter()
option (#1062)AckAll
for pull consumers. Thanks to @neilalexander for the contribution (#1063)Subscribe()
options. Thanks to @goku321 for the contribution (#1019)ConsumerMemoryStorage()
option in Subscribe()
. Thanks to @goku321 for the contribution (#1078)KV:
RePublish
option on key value configuration (#1031)ObjectStore:
ObjectStores()
and ObjectStoreNames()
methods for listing object store buckets (#1074)TLSConnectionState()
to expose TLS connection state (#996)
UserJWTAndSeed
helper function accepting JWT and seed as parameters (#1046)
natsProtoErr
type for proto error normalization and comparison using errors.Is()
(#1082)
JetStream
JetStreamError
type for all JetStream related errors, containing error codes (for API errors). JetStreamError
supports comparing and unwrapping errors using native errors
package (#1044, #1047)Subscribe()
to use memory storage and no replicas when using OrderedConsumer()
(#989)Fetch()
on pull subscription. Thanks to @wdhongtw for the contribution (#1011)PullSubscribe()
on durable semantics (#994)KV:
DirectGet()
in KV for improved performence (#1020)Add support for reporting flusher errors. THanks to @GeorgeEngland for the contribution (#1015)
Mention field defaults in Options
struct documentation. Thanks to @costela for the contribution (#1013)
DeleteMsg()
now uses NoErase
option by default, not overwriting the message on stream (only marking it as deleted) (#1025)StreamInfo()
will now return all subjects when requested (#1072)JetStream:
UseLegacyDurableConsumers()
option when creating JetStreamContext
(#1080)AccountInfo
schema (#1026)StreamSourceInfo
schema with server (#1039)Use nats-server 2.9.0 in tests (#1073)
Add new test TLS certs and run tests for go 1.18 in CI (#1023, #1055)
JetStream
Subscribe()
automatically sending ACK when AckPolicyNone
is set (#987)AckNone
consumer (#1032)ConsumerInfo
nil pointer dereference when jsi
is not initialized. Thanks to @Sergey-Belyakov for the contribution (#1024)ObjectStore
Put()
to avoid loosing last chunk when Reader
returns both value and EOF
. Thanks to @tinou98 for the contribution (#995)Get()
, not propagating errors from Get()
to the user (#1052)Put()
object meta (#1057)Typo in CustomInboxPrefix()
error message. Thanks to @subtle-byte for the contribution (#1028)
Ignore trailing comma at the end of URL lists (#1058)
https://github.com/nats-io/nats.go/compare/v1.16.0...v1.17.0
StreamConfig.RePublish
configuration, which is a SubjectMapping
(source/destination) which allows the republish of a message after being sequenced and stored (#980)ConsumerConfig
fields: Replicas
and MemoryStorage
which are generally inherited by parent stream, but can be configured directly (#980)ProxyPath()
option to add a path to websocket connection URLs. Thanks to @ido-gold-apolicy for the contribution (#974)https://github.com/nats-io/nats.go/compare/v1.15.0...v1.16.0
The ObjectStore
is still experimental and subject to change.
MaxBytes
in the ObjectStoreConfig
structure (#955)0
to nats.ExpectLastSequence(0)
and nats.ExpectLastSequencePerSubject(0)
to the js.Publish()
call. Previously, the value 0
would be ignored and the header would not be set. Note that currently, the server only accepts 0
as a valid value for nats.ExpectLastSequencePerSubject()
. Thanks to @bruth for the contribution (#958)https://github.com/nats-io/nats.go/compare/v1.14.0...v1.15.0
JetStream and KeyValue users
Please see the "Changed" section for important (possibly breaking) changes compared to the previous version.
The ObjectStore
is still experimental and subject to change.
ErrMsgAlreadyAckd
for a more detailed error when trying to acknowledge a message that already was. Thanks to @Berreek for the contribution (#862)js.Subscribe()
calls context aware (#872)UpdateConsumer()
and new consumer configuration options: MaxRequestBatch
, MaxRequestExpires
and InactiveThreshold
(#893)NakWithDelay()
new acknowledgment call, and BackOff
list of duration in the ConsumerConfig
object (#894)BackOff()
subscription option. Thanks to @mfaizanse for the contribution (#933)StallWait()
publish option. This is the wait time (default is 200ms) that the library will wait when reaching the maximum inflight number of asynchronous publish calls (#941)MetaOnly()
watcher option (#854)GetRevision()
to get the key at a specific revision, or ErrKeyNotFound
if the key does not exist or not at the expected revision. Thanks to @boxboatmatt for the contribution (#903)Placement
in the KeyValueConfig
structure (#929)nats.Context()
option for the nats.KeyWatcher
interface. Thanks to @boxboatmatt for the contribution (#904)Placement
in the ObjectStoreConfig
structure (#929)ConnectedUrlRedacted()
a redacted version of ConnectedUrl()
(#923)MaxAckPending
when creating a JetStream consumer on Subscribe()
. The selection of the value is left for the server to pick (#920)ErrNoResponders
error on a Publish()
or StreamInfo()
call. This is to overcome "blips" that may happen during leader changes. The action will be retried up to 2 times with a 250ms wait in between. These can be changed with the new publish options RetryWait()
and RetryAttempts()
(#930)PublishMsgAsync()
will now be limited to 4,000
maximum asynchronous publish calls inflight, if no maximum has been specified with PublishAsyncMaxPending()
option.Delete()
and Purge()
now accept optional DeleteOpt
options. The option available is LastRevision()
which allows the purge or delete to be conditional to the last revision be equal to the last revision value, otherwise the operation will fail. Thanks to @steveh for the contribution (#856)PurgeDeletes()
will now keep markers that are less than 30 minutes by default. Also, PurgeDeletes()
now accepts optional PurgeOpt
values, not WatchOpt
. The new DeleteMarkersOlderThan()
option can be provided to change the default 30 minutes. A negative value will remove markers, regardless of their age (#906)v2.7.2+
server, the stream for the KeyValue should be created with DiscardNew
instead of DiscardOld
. The library will now automatically update an existing stream for a KeyValue from DiscardOld
to DiscardNew
(#917)80
or 443
as default ports, depending on the scheme ws://
or wss://
. Thanks to @cbrake for the suggestion (#879)Nats-echo
service example to simulate a status request (#950)Bind
go documentation. Thanks to @caspervonb for the contribution (#860)SetClosedHandler
. Thanks to @tormoder for the contribution (#877)Subscribe
method. Thanks to @ipromax for the contribution (#886).
in their name. This resulted in situations where the API would timeout because the server did not have interest on the malformed subject. Thanks to @sata-form3 for the report (#947)ErrStreamNotFound
when calling AddConsumer
against a missing stream (#881)StreamInfo()
with nats:
to match ConsumerInfo()
(#928)Get()
returns a nil
and ErrKeyNotFound
as per specification (#844)APIPrefix
to work correctly across accounts (#910)wss://
and a host name that resolves to multiple IPs, or when trying to reconnect to discovered servers, the (re)connection would fail with websocket invalid connection
(#915)Connect()
hanging forever. Thanks to @wenerme for the report (#926)https://github.com/nats-io/nats.go/compare/v1.13.0...v1.14.0
JetStream users
Please review release notes from v1.12.0 regarding important changes if upgrading from an earlier release.
This release introduces KeyValue and ObjectStore as experimental features. Note that their APIs are subject to change based on community feedback. Also, some features will not work unless using NATS Server from the main branch, or the version following the latest public release v2.6.1.
HeadersOnly()
subscription option to only deliver headers but not the message payloads (#832)Sealed
, DenyDelete
, DenyPurge
and AllowRollup
stream configuration options (#832)GetLastMsg()
retrieves the last raw stream message stored in JetStream by subject (#832)ConnectedServerVersion()
returns the server's version string, or empty if not currently connected to a server (#832)Fetch()
and Ack()
. Thanks to @andreib1 and @T-J-L for the reports (#838)PublishMsgAsync
would fail if a message reply was already set (#832)https://github.com/nats-io/nats.go/compare/v1.12.2...v1.13.0