Skip to content

Commit

Permalink
Merge pull request #121 from ploubser/issue_114
Browse files Browse the repository at this point in the history
(#114) Fix changing `max_waiting` value when `delivery_subject` is set
  • Loading branch information
ripienaar authored Aug 22, 2024
2 parents 885efde + d450b9b commit b03bda9
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 7 deletions.
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

0 comments on commit b03bda9

Please sign in to comment.