mirror of
https://github.com/vmware-tanzu/pinniped.git
synced 2026-01-03 03:35:46 +00:00
Pull controller-go back into this repository as internal/controllerlib.
Signed-off-by: Matt Moyer <moyerm@vmware.com>
This commit is contained in:
41
internal/controllerlib/queue.go
Normal file
41
internal/controllerlib/queue.go
Normal file
@@ -0,0 +1,41 @@
|
||||
/*
|
||||
Copyright 2020 VMware, Inc.
|
||||
SPDX-License-Identifier: Apache-2.0
|
||||
*/
|
||||
|
||||
package controllerlib
|
||||
|
||||
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