Skip to content

Commit

Permalink
Add InactiveThreshold parsing
Browse files Browse the repository at this point in the history
  • Loading branch information
samuelattwood committed Jan 13, 2025
1 parent ff5d00a commit 799db81
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 5 deletions.
11 changes: 8 additions & 3 deletions internal/controller/consumer_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -253,9 +253,6 @@ func consumerSpecToConfig(spec *api.ConsumerSpec) (*jetstream.ConsumerConfig, er
MemoryStorage: spec.MemStorage,
FilterSubjects: spec.FilterSubjects,
Metadata: spec.Metadata,

// Explicitly set not (yet) mapped fields
InactiveThreshold: 0,
}

// DeliverPolicy
Expand Down Expand Up @@ -319,6 +316,14 @@ func consumerSpecToConfig(spec *api.ConsumerSpec) (*jetstream.ConsumerConfig, er
config.MaxRequestExpires = d
}

if spec.InactiveThreshold != "" {
d, err := time.ParseDuration(spec.InactiveThreshold)
if err != nil {
return nil, fmt.Errorf("invalid inactive threshold: %w", err)
}
config.InactiveThreshold = d
}

return config, nil
}

Expand Down
4 changes: 2 additions & 2 deletions internal/controller/suite_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ import (
logf "sigs.k8s.io/controller-runtime/pkg/log"
"sigs.k8s.io/controller-runtime/pkg/log/zap"

jetstreamnatsiov1beta2 "github.com/nats-io/nack/pkg/jetstream/apis/jetstream/v1beta2"
api "github.com/nats-io/nack/pkg/jetstream/apis/jetstream/v1beta2"
)

// These tests use Ginkgo (BDD-style Go testing framework). Refer to
Expand Down Expand Up @@ -80,7 +80,7 @@ var _ = BeforeSuite(func() {
Expect(err).NotTo(HaveOccurred())
Expect(cfg).NotTo(BeNil())

err = jetstreamnatsiov1beta2.AddToScheme(scheme.Scheme)
err = api.AddToScheme(scheme.Scheme)
Expect(err).NotTo(HaveOccurred())

k8sClient, err = client.New(cfg, client.Options{Scheme: scheme.Scheme})
Expand Down

0 comments on commit 799db81

Please sign in to comment.