From 58f8b40dc141a86a6693cf2bf10cbcdbde409c66 Mon Sep 17 00:00:00 2001 From: Eric Jacobson Date: Tue, 3 Mar 2026 09:44:50 -0500 Subject: [PATCH] feat: warn when multiple trim strategies are specified Signed-off-by: Eric Jacobson --- pubsub/redis/metadata.yaml | 8 ++++++-- pubsub/redis/redis.go | 4 ++++ 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/pubsub/redis/metadata.yaml b/pubsub/redis/metadata.yaml index 9ccd81083c..195833d10f 100644 --- a/pubsub/redis/metadata.yaml +++ b/pubsub/redis/metadata.yaml @@ -227,7 +227,10 @@ metadata: type: string - name: maxLenApprox required: false - description: Maximum number of items inside a stream. The old entries are automatically evicted when the specified length is reached, so that the stream is left at a constant size. Defaults to unlimited. + description: | + Maximum number of items inside a stream. The old entries are automatically evicted when the specified length is reached, + so that the stream is left at a constant size. Defaults to unlimited. + Cannot be used together with streamTTL; only one stream trimming strategy can be active at a time. example: "10000" type: number - name: streamTTL @@ -237,6 +240,7 @@ metadata: This is an approximate value, as it's implemented using Redis stream's MINID trimming with the '~' modifier. The actual retention may include slightly more entries than strictly defined by the TTL, as Redis optimizes the trimming operation for efficiency by potentially keeping some additional entries. + Cannot be used together with maxLenApprox; only one stream trimming strategy can be active at a time. example: "30d" type: duration @@ -254,4 +258,4 @@ builtinAuthenticationProfiles: - name: enableTLS required: true description: Must be set to true if using EntraID - example: "true" \ No newline at end of file + example: "true" diff --git a/pubsub/redis/redis.go b/pubsub/redis/redis.go index 9cd8629d47..f745a8dd4a 100644 --- a/pubsub/redis/redis.go +++ b/pubsub/redis/redis.go @@ -85,6 +85,10 @@ func (r *redisStreams) Init(ctx context.Context, metadata pubsub.Metadata) error if _, err = r.client.PingResult(ctx); err != nil { return fmt.Errorf("redis streams: error connecting to redis at %s: %s", r.clientSettings.Host, err) } + + if r.clientSettings.MaxLenApprox > 0 && r.clientSettings.StreamTTL > 0 { + r.logger.Warn("redis streams: maxLenApprox and streamTTL cannot be used together; only one stream trimming strategy can be active at a time.") + } r.queue = make(chan redisMessageWrapper, int(r.clientSettings.QueueDepth)) //nolint:gosec for range r.clientSettings.Concurrency {