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

[IMPROVED] Add extra option to OrderedConsumerConfig #1737

Merged
merged 1 commit into from
Dec 19, 2024
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
5 changes: 5 additions & 0 deletions jetstream/consumer_config.go
Original file line number Diff line number Diff line change
Expand Up @@ -263,6 +263,11 @@ type (
// Maximum number of attempts for the consumer to be recreated in a
// single recreation cycle. Defaults to unlimited.
MaxResetAttempts int

// Metadata is a set of application-defined key-value pairs for
// associating metadata on the consumer. This feature requires
// nats-server v2.10.0 or later.
Metadata map[string]string `json:"metadata,omitempty"`
}

// DeliverPolicy determines from which point to start delivering messages.
Expand Down
1 change: 1 addition & 0 deletions jetstream/ordered.go
Original file line number Diff line number Diff line change
Expand Up @@ -604,6 +604,7 @@ func (c *orderedConsumer) getConsumerConfig() *ConsumerConfig {
Replicas: 1,
HeadersOnly: c.cfg.HeadersOnly,
MemoryStorage: true,
Metadata: c.cfg.Metadata,
}
if len(c.cfg.FilterSubjects) == 1 {
cfg.FilterSubject = c.cfg.FilterSubjects[0]
Expand Down
4 changes: 4 additions & 0 deletions jetstream/test/ordered_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -1952,6 +1952,7 @@ func TestOrderedConsumerConfig(t *testing.T) {
ReplayPolicy: jetstream.ReplayOriginalPolicy,
InactiveThreshold: 10 * time.Second,
HeadersOnly: true,
Metadata: map[string]string{"foo": "a"},
},
expected: jetstream.ConsumerConfig{
FilterSubjects: []string{"foo.a", "foo.b"},
Expand All @@ -1964,6 +1965,7 @@ func TestOrderedConsumerConfig(t *testing.T) {
Replicas: 1,
MemoryStorage: true,
HeadersOnly: true,
Metadata: map[string]string{"foo": "a"},
},
},
{
Expand All @@ -1975,6 +1977,7 @@ func TestOrderedConsumerConfig(t *testing.T) {
ReplayPolicy: jetstream.ReplayOriginalPolicy,
InactiveThreshold: 10 * time.Second,
HeadersOnly: true,
Metadata: map[string]string{"foo": "a"},
},
expected: jetstream.ConsumerConfig{
FilterSubjects: []string{"foo.a", "foo.b"},
Expand All @@ -1987,6 +1990,7 @@ func TestOrderedConsumerConfig(t *testing.T) {
Replicas: 1,
MemoryStorage: true,
HeadersOnly: true,
Metadata: map[string]string{"foo": "a"},
},
},
}
Expand Down
Loading