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

(#114) Fix changing max_waiting value when delivery_subject is set #121

Merged
merged 1 commit into from
Aug 22, 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
20 changes: 13 additions & 7 deletions jetstream/resource_jetstream_consumer.go
Original file line number Diff line number Diff line change
Expand Up @@ -193,12 +193,13 @@ func resourceConsumer() *schema.Resource {
ForceNew: true,
},
"max_waiting": {
Type: schema.TypeInt,
Description: "The number of pulls that can be outstanding on a pull consumer, pulls received after this is reached are ignored",
Optional: true,
Default: 512,
ForceNew: false,
ValidateFunc: validation.IntAtLeast(0),
Type: schema.TypeInt,
Description: "The number of pulls that can be outstanding on a pull consumer, pulls received after this is reached are ignored",
Optional: true,
Computed: true,
ConflictsWith: []string{"delivery_subject"},
ForceNew: false,
ValidateFunc: validation.IntAtLeast(0),
},
"headers_only": {
Type: schema.TypeBool,
Expand Down Expand Up @@ -291,7 +292,12 @@ func consumerConfigFromResourceData(d *schema.ResourceData) (cfg api.ConsumerCon
if cfg.DeliverSubject != "" {
cfg.DeliverGroup = d.Get("delivery_group").(string)
} else {
cfg.MaxWaiting = d.Get("max_waiting").(int)
if max_waiting := d.Get("max_waiting").(int); max_waiting == 0 {
// set default value. default cannot be set because this field is computed
max_waiting = 512
} else {
cfg.MaxWaiting = max_waiting
}
}

for _, d := range d.Get("backoff").([]any) {
Expand Down
2 changes: 2 additions & 0 deletions jetstream/resource_jetstream_consumer_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@ resource "jetstream_consumer" "TEST_C2" {
stream_sequence = 10
max_ack_pending = 20
filter_subjects = ["TEST.a", "TEST.b"]
max_waiting = 10
}
`

Expand All @@ -70,6 +71,7 @@ resource "jetstream_consumer" "TEST_C3" {
stream_sequence = 10
max_ack_pending = 20
filter_subject = "TEST.a"
delivery_subject = "ORDERS.a"
}
`

Expand Down
Loading