From dcaea4c5dc209d065dbafb0f5c2e6b272ce3a5ee Mon Sep 17 00:00:00 2001 From: Darren Shepherd Date: Mon, 22 Oct 2018 10:51:15 -0700 Subject: [PATCH] All per controller threadiness --- controller/generic_controller.go | 21 +++++++++++++++------ 1 file changed, 15 insertions(+), 6 deletions(-) diff --git a/controller/generic_controller.go b/controller/generic_controller.go index 32efe1ee..d1b215fe 100644 --- a/controller/generic_controller.go +++ b/controller/generic_controller.go @@ -44,6 +44,7 @@ func init() { type HandlerFunc func(key string) error type GenericController interface { + SetThreadinessOverride(count int) Informer() cache.SharedIndexInformer AddHandler(name string, handler HandlerFunc) HandlerCount() int @@ -65,12 +66,13 @@ type handlerDef struct { type genericController struct { sync.Mutex - informer cache.SharedIndexInformer - handlers []handlerDef - queue workqueue.RateLimitingInterface - name string - running bool - synced bool + threadinessOverride int + informer cache.SharedIndexInformer + handlers []handlerDef + queue workqueue.RateLimitingInterface + name string + running bool + synced bool } func NewGenericController(name string, genericClient Backend) GenericController { @@ -94,6 +96,10 @@ func NewGenericController(name string, genericClient Backend) GenericController } } +func (g *genericController) SetThreadinessOverride(count int) { + g.threadinessOverride = count +} + func (g *genericController) HandlerCount() int { return len(g.handlers) } @@ -163,6 +169,9 @@ func (g *genericController) Start(ctx context.Context, threadiness int) error { } if !g.running { + if g.threadinessOverride > 0 { + threadiness = g.threadinessOverride + } go g.run(ctx, threadiness) }