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

[ADDED] Description in StreamConfig and ConsumerConfig #795

Merged
merged 1 commit into from Aug 17, 2021
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.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
1 change: 1 addition & 0 deletions js.go
Expand Up @@ -772,6 +772,7 @@ func Context(ctx context.Context) ContextOpt {
// ConsumerConfig is the configuration of a JetStream consumer.
type ConsumerConfig struct {
Durable string `json:"durable_name,omitempty"`
Description string `json:"description,omitempty"`
DeliverSubject string `json:"deliver_subject,omitempty"`
DeliverGroup string `json:"deliver_group,omitempty"`
DeliverPolicy DeliverPolicy `json:"deliver_policy"`
Expand Down
1 change: 1 addition & 0 deletions jsm.go
Expand Up @@ -75,6 +75,7 @@ type JetStreamManager interface {
// given the name will be used as the only subject.
type StreamConfig struct {
Name string `json:"name"`
Description string `json:"description,omitempty"`
Subjects []string `json:"subjects,omitempty"`
Retention RetentionPolicy `json:"retention"`
MaxConsumers int `json:"max_consumers"`
Expand Down
46 changes: 46 additions & 0 deletions test/js_test.go
Expand Up @@ -5915,3 +5915,49 @@ func TestJetStreamDomainInPubAck(t *testing.T) {
t.Fatalf("Expected PubAck to have domain of %q, got %q", "HUB", pa.Domain)
}
}

func TestJetStreamStreamAndConsumerDescription(t *testing.T) {
s := RunBasicJetStreamServer()
defer s.Shutdown()

if config := s.JetStreamConfig(); config != nil {
defer os.RemoveAll(config.StoreDir)
}

nc, err := nats.Connect(s.ClientURL())
if err != nil {
t.Fatalf("Unexpected error: %v", err)
}
defer nc.Close()

js, err := nc.JetStream()
if err != nil {
t.Fatalf("Unexpected error: %v", err)
}

streamDesc := "stream description"
si, err := js.AddStream(&nats.StreamConfig{
Name: "TEST",
Description: streamDesc,
Subjects: []string{"foo"},
})
if err != nil {
t.Fatalf("Error adding stream: %v", err)
}
if si.Config.Description != streamDesc {
t.Fatalf("Invalid description: %q vs %q", streamDesc, si.Config.Description)
}

consDesc := "consumer description"
ci, err := js.AddConsumer("TEST", &nats.ConsumerConfig{
Description: consDesc,
Durable: "dur",
DeliverSubject: "bar",
})
if err != nil {
t.Fatalf("Error adding consumer: %v", err)
}
if ci.Config.Description != consDesc {
t.Fatalf("Invalid description: %q vs %q", consDesc, ci.Config.Description)
}
}