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 setting consumer replicas though options #1019
Changes from 4 commits
5240d8e
c5c2b8e
f732c53
122e3a1
1d9feeb
aff87fc
c50c8f9
dbc90ca
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -1026,3 +1026,33 @@ func TestJetStreamClusterPlacement(t *testing.T) { | |
t.Fatalf("Unexpected tag: %q", v) | ||
} | ||
} | ||
|
||
func TestConsumerReplicasOption(t *testing.T) { | ||
s := RunBasicJetStreamServer() | ||
defer shutdownJSServerAndRemoveStorage(t, s) | ||
|
||
nc, js := jsClient(t, s) | ||
defer nc.Close() | ||
|
||
if _, err := js.AddStream(&StreamConfig{Name: "CONSUMER_REPLICAS_TEST", Subjects: []string{"foo"}}); err != nil { | ||
t.Fatalf("Error adding stream: %v", err) | ||
} | ||
|
||
cb := func(msg *Msg) {} | ||
// Subscribe to the stream with a durable consumer "bar". | ||
_, err := js.Subscribe("foo", cb, Durable("bar"), ConsumerReplicas(1)) | ||
if err != nil { | ||
t.Fatalf("Unexpected error: %v", err) | ||
} | ||
|
||
// Get consumer info | ||
consInfo, err := js.ConsumerInfo("CONSUMER_REPLICAS_TEST", "bar") | ||
if err != nil { | ||
t.Fatalf("Unexpected error: %v", err) | ||
} | ||
|
||
// Check if the number of replicas is the same as we provided. | ||
if consInfo.Config.Replicas != 1 { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. To be fair, this test does not prove anything since even if ConsumerReplicas() was doing nothing, this test would pass, simply because the stream itself is replicas 1, so the new consumer would inherit this value. So the test should either be moved to There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @kozlovic I totally agree on this. Will make the changes |
||
t.Fatalf("Expected consumer replica to be %v, got %+v", 1, consInfo.Config.Replicas) | ||
} | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think we can also consider setting adding
&& replicas <=5
, as that is the upper limit.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That is the current server limit, but since server defined and we could change would leave that out..