mirror of
https://github.com/vmware-tanzu/pinniped.git
synced 2026-08-31 13:17:09 +00:00
Add initial controller boilerplate and example controller
Signed-off-by: Monis Khan <mok@vmware.com>
This commit is contained in:
@@ -0,0 +1,41 @@
|
||||
/*
|
||||
Copyright 2020 VMware, Inc.
|
||||
SPDX-License-Identifier: Apache-2.0
|
||||
*/
|
||||
|
||||
package controller
|
||||
|
||||
import (
|
||||
"time"
|
||||
|
||||
"k8s.io/client-go/util/workqueue"
|
||||
)
|
||||
|
||||
type Queue interface {
|
||||
// Add immediately adds a key to the queue and marks it as needing processing.
|
||||
Add(key Key)
|
||||
|
||||
// AddRateLimited adds a key to the queue after the rate limiter says it is ok.
|
||||
AddRateLimited(key Key)
|
||||
|
||||
// AddAfter adds a key to the queue after the indicated duration has passed.
|
||||
AddAfter(key Key, duration time.Duration)
|
||||
}
|
||||
|
||||
var _ Queue = &queueWrapper{}
|
||||
|
||||
type queueWrapper struct {
|
||||
queue workqueue.RateLimitingInterface
|
||||
}
|
||||
|
||||
func (q *queueWrapper) Add(key Key) {
|
||||
q.queue.Add(key)
|
||||
}
|
||||
|
||||
func (q *queueWrapper) AddRateLimited(key Key) {
|
||||
q.queue.AddRateLimited(key)
|
||||
}
|
||||
|
||||
func (q *queueWrapper) AddAfter(key Key, duration time.Duration) {
|
||||
q.queue.AddAfter(key, duration)
|
||||
}
|
||||
Reference in New Issue
Block a user