mirror of
https://github.com/rancher/norman.git
synced 2025-09-02 07:44:51 +00:00
Add EnqueueAfter
This commit is contained in:
@@ -50,6 +50,7 @@ type GenericController interface {
|
|||||||
AddHandler(ctx context.Context, name string, handler HandlerFunc)
|
AddHandler(ctx context.Context, name string, handler HandlerFunc)
|
||||||
HandlerCount() int
|
HandlerCount() int
|
||||||
Enqueue(namespace, name string)
|
Enqueue(namespace, name string)
|
||||||
|
EnqueueAfter(namespace, name string, after time.Duration)
|
||||||
Sync(ctx context.Context) error
|
Sync(ctx context.Context) error
|
||||||
Start(ctx context.Context, threadiness int) 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) {
|
func (g *genericController) AddHandler(ctx context.Context, name string, handler HandlerFunc) {
|
||||||
t := getHandlerTransaction(ctx)
|
t := getHandlerTransaction(ctx)
|
||||||
if t == nil {
|
if t == nil {
|
||||||
|
@@ -4,6 +4,7 @@ var controllerTemplate = `package {{.schema.Version.Version}}
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"context"
|
"context"
|
||||||
|
"time"
|
||||||
|
|
||||||
{{.importPackage}}
|
{{.importPackage}}
|
||||||
"github.com/rancher/norman/objectclient"
|
"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)
|
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)
|
AddClusterScopedFeatureHandler(ctx context.Context, enabled func() bool, name, clusterName string, handler {{.schema.CodeName}}HandlerFunc)
|
||||||
Enqueue(namespace, name string)
|
Enqueue(namespace, name string)
|
||||||
|
EnqueueAfter(namespace, name string, after time.Duration)
|
||||||
Sync(ctx context.Context) error
|
Sync(ctx context.Context) error
|
||||||
Start(ctx context.Context, threadiness int) error
|
Start(ctx context.Context, threadiness int) error
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user