From 7a404f57ef0ec8030625e84920caf7ba5312a122 Mon Sep 17 00:00:00 2001 From: sirko Date: Mon, 9 Dec 2024 16:03:18 +0100 Subject: [PATCH] add support for throttle wildcard docs: > alternatively the wildcard '*' can be used to throttle all replicas for this topic. This adds support for that --- pkg/config/settings.go | 6 ++++++ pkg/config/settings_test.go | 8 ++++++++ 2 files changed, 14 insertions(+) diff --git a/pkg/config/settings.go b/pkg/config/settings.go index 1a5c6621..b48cbcd1 100644 --- a/pkg/config/settings.go +++ b/pkg/config/settings.go @@ -62,6 +62,9 @@ var keyValidators = map[string]configValidator{ return intVal >= 0 }, "follower.replication.throttled.replicas": func(v string) bool { + if v == "*" { + return true + } subValues := strings.Split(v, ",") for _, subValue := range subValues { elements := strings.Split(subValue, ":") @@ -86,6 +89,9 @@ var keyValidators = map[string]configValidator{ return intVal >= 0 }, "leader.replication.throttled.replicas": func(v string) bool { + if v == "*" { + return true + } subValues := strings.Split(v, ",") for _, subValue := range subValues { elements := strings.Split(subValue, ":") diff --git a/pkg/config/settings_test.go b/pkg/config/settings_test.go index 4d7bcdba..f9d48812 100644 --- a/pkg/config/settings_test.go +++ b/pkg/config/settings_test.go @@ -57,6 +57,14 @@ func TestValidateSettings(t *testing.T) { }, expError: false, }, + { + description: "wildcard throttle", + settings: TopicSettings{ + "follower.replication.throttled.replicas": "*", + "leader.replication.throttled.replicas": "*", + }, + expError: false, + }, { description: "unrecognized key", settings: TopicSettings{