mirror of
https://github.com/rancher/norman.git
synced 2025-08-31 14:51:57 +00:00
Add EnqueueAfter
This commit is contained in:
@@ -50,6 +50,7 @@ type GenericController interface {
|
||||
AddHandler(ctx context.Context, name string, handler HandlerFunc)
|
||||
HandlerCount() int
|
||||
Enqueue(namespace, name string)
|
||||
EnqueueAfter(namespace, name string, after time.Duration)
|
||||
Sync(ctx context.Context) error
|
||||
Start(ctx context.Context, threadiness int) error
|
||||
}
|
||||
@@ -122,6 +123,16 @@ func (g *genericController) Enqueue(namespace, name string) {
|
||||
}
|
||||
}
|
||||
|
||||
func (g *genericController) EnqueueAfter(namespace, name string, after time.Duration) {
|
||||
key := name
|
||||
if namespace != "" {
|
||||
key = namespace + "/" + name
|
||||
}
|
||||
if g.queue != nil {
|
||||
g.queue.AddAfter(key, after)
|
||||
}
|
||||
}
|
||||
|
||||
func (g *genericController) AddHandler(ctx context.Context, name string, handler HandlerFunc) {
|
||||
t := getHandlerTransaction(ctx)
|
||||
if t == nil {
|
||||
|
@@ -4,6 +4,7 @@ var controllerTemplate = `package {{.schema.Version.Version}}
|
||||
|
||||
import (
|
||||
"context"
|
||||
"time"
|
||||
|
||||
{{.importPackage}}
|
||||
"github.com/rancher/norman/objectclient"
|
||||
@@ -78,6 +79,7 @@ type {{.schema.CodeName}}Controller interface {
|
||||
AddClusterScopedHandler(ctx context.Context, name, clusterName string, handler {{.schema.CodeName}}HandlerFunc)
|
||||
AddClusterScopedFeatureHandler(ctx context.Context, enabled func() bool, name, clusterName string, handler {{.schema.CodeName}}HandlerFunc)
|
||||
Enqueue(namespace, name string)
|
||||
EnqueueAfter(namespace, name string, after time.Duration)
|
||||
Sync(ctx context.Context) error
|
||||
Start(ctx context.Context, threadiness int) error
|
||||
}
|
||||
|
Reference in New Issue
Block a user