Skip to content

Commit 58f8b40

Browse files
committed
feat: warn when multiple trim strategies are specified
Signed-off-by: Eric Jacobson <eric.jacobson@grafana.com>
1 parent 6676a35 commit 58f8b40

File tree

2 files changed

+10
-2
lines changed

2 files changed

+10
-2
lines changed

pubsub/redis/metadata.yaml

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -227,7 +227,10 @@ metadata:
227227
type: string
228228
- name: maxLenApprox
229229
required: false
230-
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.
230+
description: |
231+
Maximum number of items inside a stream. The old entries are automatically evicted when the specified length is reached,
232+
so that the stream is left at a constant size. Defaults to unlimited.
233+
Cannot be used together with streamTTL; only one stream trimming strategy can be active at a time.
231234
example: "10000"
232235
type: number
233236
- name: streamTTL
@@ -237,6 +240,7 @@ metadata:
237240
This is an approximate value, as it's implemented using Redis stream's MINID trimming with the '~' modifier.
238241
The actual retention may include slightly more entries than strictly defined by the TTL,
239242
as Redis optimizes the trimming operation for efficiency by potentially keeping some additional entries.
243+
Cannot be used together with maxLenApprox; only one stream trimming strategy can be active at a time.
240244
example: "30d"
241245
type: duration
242246

@@ -254,4 +258,4 @@ builtinAuthenticationProfiles:
254258
- name: enableTLS
255259
required: true
256260
description: Must be set to true if using EntraID
257-
example: "true"
261+
example: "true"

pubsub/redis/redis.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -85,6 +85,10 @@ func (r *redisStreams) Init(ctx context.Context, metadata pubsub.Metadata) error
8585
if _, err = r.client.PingResult(ctx); err != nil {
8686
return fmt.Errorf("redis streams: error connecting to redis at %s: %s", r.clientSettings.Host, err)
8787
}
88+
89+
if r.clientSettings.MaxLenApprox > 0 && r.clientSettings.StreamTTL > 0 {
90+
r.logger.Warn("redis streams: maxLenApprox and streamTTL cannot be used together; only one stream trimming strategy can be active at a time.")
91+
}
8892
r.queue = make(chan redisMessageWrapper, int(r.clientSettings.QueueDepth)) //nolint:gosec
8993

9094
for range r.clientSettings.Concurrency {

0 commit comments

Comments
 (0)