Skip to content

Commit

Permalink
feat(events/natsjs): allow disabling durable streams
Browse files Browse the repository at this point in the history
Signed-off-by: jkoberg <jkoberg@owncloud.com>
  • Loading branch information
kobergj committed Nov 30, 2023
1 parent d72facc commit 48ccb79
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 10 deletions.
6 changes: 4 additions & 2 deletions v4/events/natsjs/nats.go
Original file line number Diff line number Diff line change
Expand Up @@ -203,8 +203,10 @@ func (s *stream) Consume(topic string, opts ...events.ConsumeOption) (<-chan eve
}

// setup the options
subOpts := []nats.SubOpt{
nats.Durable(options.Group),
subOpts := []nats.SubOpt{}

if !s.opts.DisableDurableStreams {
subOpts = append(subOpts, nats.Durable(options.Group))
}

if options.CustomRetries {
Expand Down
24 changes: 16 additions & 8 deletions v4/events/natsjs/options.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,14 +8,15 @@ import (

// Options which are used to configure the nats stream.
type Options struct {
ClusterID string
ClientID string
Address string
NkeyConfig string
TLSConfig *tls.Config
Logger logger.Logger
SyncPublish bool
Name string
ClusterID string
ClientID string
Address string
NkeyConfig string
TLSConfig *tls.Config
Logger logger.Logger
SyncPublish bool
Name string
DisableDurableStreams bool
}

// Option is a function which configures options.
Expand Down Expand Up @@ -76,3 +77,10 @@ func Name(name string) Option {
o.Name = name
}
}

// DisableDurableStreams will disable durable streams
func DisableDurableStreams() Option {
return func(o *Options) {
o.DisableDurableStreams = true
}
}

0 comments on commit 48ccb79

Please sign in to comment.