mirror of
https://github.com/rancher/norman.git
synced 2025-09-01 15:18:20 +00:00
Add ability to add handlers transactionally across controllers
This commit is contained in:
@@ -123,6 +123,20 @@ func (g *genericController) Enqueue(namespace, name string) {
|
||||
}
|
||||
|
||||
func (g *genericController) AddHandler(ctx context.Context, name string, handler HandlerFunc) {
|
||||
t := getHandlerTransaction(ctx)
|
||||
if t == nil {
|
||||
g.addHandler(ctx, name, handler)
|
||||
return
|
||||
}
|
||||
|
||||
go func() {
|
||||
if t.shouldContinue() {
|
||||
g.addHandler(ctx, name, handler)
|
||||
}
|
||||
}()
|
||||
}
|
||||
|
||||
func (g *genericController) addHandler(ctx context.Context, name string, handler HandlerFunc) {
|
||||
g.Lock()
|
||||
defer g.Unlock()
|
||||
|
||||
|
Reference in New Issue
Block a user