Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow disabling durable streams #131

Merged
merged 1 commit into from
Nov 30, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
}
}
Loading