1
0
mirror of https://github.com/rancher/norman.git synced 2025-09-01 15:18:20 +00:00

All per controller threadiness

This commit is contained in:
Darren Shepherd
2018-10-22 10:51:15 -07:00
parent 04cb04ac06
commit dcaea4c5dc

View File

@@ -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)
}