mirror of
https://github.com/rancher/norman.git
synced 2025-09-01 23:36:58 +00:00
All per controller threadiness
This commit is contained in:
@@ -44,6 +44,7 @@ func init() {
|
|||||||
type HandlerFunc func(key string) error
|
type HandlerFunc func(key string) error
|
||||||
|
|
||||||
type GenericController interface {
|
type GenericController interface {
|
||||||
|
SetThreadinessOverride(count int)
|
||||||
Informer() cache.SharedIndexInformer
|
Informer() cache.SharedIndexInformer
|
||||||
AddHandler(name string, handler HandlerFunc)
|
AddHandler(name string, handler HandlerFunc)
|
||||||
HandlerCount() int
|
HandlerCount() int
|
||||||
@@ -65,12 +66,13 @@ type handlerDef struct {
|
|||||||
|
|
||||||
type genericController struct {
|
type genericController struct {
|
||||||
sync.Mutex
|
sync.Mutex
|
||||||
informer cache.SharedIndexInformer
|
threadinessOverride int
|
||||||
handlers []handlerDef
|
informer cache.SharedIndexInformer
|
||||||
queue workqueue.RateLimitingInterface
|
handlers []handlerDef
|
||||||
name string
|
queue workqueue.RateLimitingInterface
|
||||||
running bool
|
name string
|
||||||
synced bool
|
running bool
|
||||||
|
synced bool
|
||||||
}
|
}
|
||||||
|
|
||||||
func NewGenericController(name string, genericClient Backend) GenericController {
|
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 {
|
func (g *genericController) HandlerCount() int {
|
||||||
return len(g.handlers)
|
return len(g.handlers)
|
||||||
}
|
}
|
||||||
@@ -163,6 +169,9 @@ func (g *genericController) Start(ctx context.Context, threadiness int) error {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if !g.running {
|
if !g.running {
|
||||||
|
if g.threadinessOverride > 0 {
|
||||||
|
threadiness = g.threadinessOverride
|
||||||
|
}
|
||||||
go g.run(ctx, threadiness)
|
go g.run(ctx, threadiness)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user