From dbb41e7512ec68607974ce57fafd4350747e73a7 Mon Sep 17 00:00:00 2001 From: ilyamor Date: Wed, 19 Aug 2020 14:14:03 +0300 Subject: [PATCH 1/2] add support for multiple redis list types Signed-off-by: ilyamor --- pkg/scalers/redis_scaler.go | 23 ++++++++++++++++++++++- 1 file changed, 22 insertions(+), 1 deletion(-) diff --git a/pkg/scalers/redis_scaler.go b/pkg/scalers/redis_scaler.go index 0ac0087a712..04ba277be71 100644 --- a/pkg/scalers/redis_scaler.go +++ b/pkg/scalers/redis_scaler.go @@ -206,9 +206,30 @@ func getRedisListLength(ctx context.Context, address string, password string, li } client := redis.NewClient(options) + var listType *redis.StatusCmd - cmd := client.LLen(listName) + listType = client.Type(listName) + if listType.Err() != nil { + return -1, listType.Err() + } + + var cmd *redis.IntCmd + switch listType.Val() { + case "list": + cmd = client.LLen(listName) + case "set": + cmd = client.SCard(listName) + case "hash": + cmd = client.HLen(listName) + case "zset": + cmd = client.ZCard(listName) + default: + cmd = nil + } + if cmd == nil { + return -1, fmt.Errorf("list must be of type:list,set,hash,zset but was %s", listType.Val()) + } if cmd.Err() != nil { return -1, cmd.Err() } From 6b268a4f6e0fe1bac2ef3a39cabb90e428088145 Mon Sep 17 00:00:00 2001 From: ilyamor Date: Wed, 19 Aug 2020 14:21:24 +0300 Subject: [PATCH 2/2] Provide changelog for v2.0 (#1006) Signed-off-by: ilyamor --- CHANGELOG.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 7a4b8f5854a..9c87654b517 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -28,7 +28,7 @@ - Add consumer offset reset policy option to Kafka scaler ([#925](https://github.com/kedacore/keda/pull/925)) - Add option to restore to original replica count after ScaledObject's deletion ([#219](https://github.com/kedacore/keda-docs/pull/219)) - Add Prometheus metrics for KEDA Metrics API Server ([#823](https://github.com/kedacore/keda/issues/823) | [docs](https://keda.sh/docs/2.0/operate/#prometheus-exporter-metrics)) - +- add support for multiple redis list types in redis list scaler ([#1006](https://github.com/kedacore/keda/pull/1006)) | [docs](https://keda.sh/docs/2.0/scalers/redis-lists/)) ### Improvements - HPA: move from autoscaling v2beta1 to v2beta2 ([#721](https://github.com/kedacore/keda/issues/721))