1
0
mirror of https://github.com/go-micro/go-micro.git synced 2024-12-30 10:10:44 +02:00

Correctly check error on redis command XTRIM (#2518)

Also:
 - add comment about version requirement
 - move minID to var for code readability
This commit is contained in:
Thomas Chandelle 2022-06-30 12:24:27 +02:00 committed by GitHub
parent 65a2e4ed02
commit 87c96bc4d0
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -71,7 +71,9 @@ func (r *redisStream) cleanupConsumers() error {
}
}
if err := r.redisClient.XTrimMinID(ctx, streamName, strconv.FormatInt(time.Now().Add(-d).Unix()*1000, 10)); err != nil {
// `XTRIM MINID` requires Redis 6.2
minID := strconv.FormatInt(time.Now().Add(-d).Unix()*1000, 10)
if err := r.redisClient.XTrimMinID(ctx, streamName, minID).Err(); err != nil {
logger.Errorf("Error trimming %s", err)
}
}