From 4b3ba718d0c52deff699abc67b092f57b2561e90 Mon Sep 17 00:00:00 2001 From: Piotr Piotrowski Date: Wed, 14 Feb 2024 09:33:38 +0100 Subject: [PATCH] [IMPROVED] AddConsumer documentation (#1555) Signed-off-by: Piotr Piotrowski --- jetstream/jetstream_options.go | 2 +- jsm.go | 10 +++++++++- 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/jetstream/jetstream_options.go b/jetstream/jetstream_options.go index 699a9013e..a08d203fb 100644 --- a/jetstream/jetstream_options.go +++ b/jetstream/jetstream_options.go @@ -278,7 +278,7 @@ func FetchMaxWait(timeout time.Duration) FetchOpt { // // Heartbeat value has to be lower than FetchMaxWait / 2. // -// If not provided, heartbeat will is set to 5s for requests with FetchMaxWait > 30s +// If not provided, heartbeat will is set to 5s for requests with FetchMaxWait > 10s // and disabled otherwise. func FetchHeartbeat(hb time.Duration) FetchOpt { return func(req *pullRequest) error { diff --git a/jsm.go b/jsm.go index 8f724726b..94fa86c32 100644 --- a/jsm.go +++ b/jsm.go @@ -70,6 +70,10 @@ type JetStreamManager interface { SecureDeleteMsg(name string, seq uint64, opts ...JSOpt) error // AddConsumer adds a consumer to a stream. + // If the consumer already exists, and the configuration is the same, it + // will return the existing consumer. + // If the consumer already exists, and the configuration is different, it + // will return ErrConsumerNameAlreadyInUse. AddConsumer(stream string, cfg *ConsumerConfig, opts ...JSOpt) (*ConsumerInfo, error) // UpdateConsumer updates an existing consumer. @@ -329,7 +333,11 @@ type consumerResponse struct { *ConsumerInfo } -// AddConsumer will add a JetStream consumer. +// AddConsumer adds a consumer to a stream. +// If the consumer already exists, and the configuration is the same, it +// will return the existing consumer. +// If the consumer already exists, and the configuration is different, it +// will return ErrConsumerNameAlreadyInUse. func (js *js) AddConsumer(stream string, cfg *ConsumerConfig, opts ...JSOpt) (*ConsumerInfo, error) { if cfg == nil { cfg = &ConsumerConfig{}