Skip to content

Commit 3481525

Browse files
authored
Merge pull request kubernetes#89348 from fatedier/workqueue
Export new constructor for DelayingQueue
2 parents 7e7c4d1 + b5d989a commit 3481525

File tree

1 file changed

+11
-2
lines changed

1 file changed

+11
-2
lines changed

staging/src/k8s.io/client-go/util/workqueue/delaying_queue.go

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,12 @@ func NewDelayingQueue() DelayingInterface {
3838
return NewDelayingQueueWithCustomClock(clock.RealClock{}, "")
3939
}
4040

41+
// NewDelayingQueueWithCustomQueue constructs a new workqueue with ability to
42+
// inject custom queue Interface instead of the default one
43+
func NewDelayingQueueWithCustomQueue(q Interface, name string) DelayingInterface {
44+
return newDelayingQueue(clock.RealClock{}, q, name)
45+
}
46+
4147
// NewNamedDelayingQueue constructs a new named workqueue with delayed queuing ability
4248
func NewNamedDelayingQueue(name string) DelayingInterface {
4349
return NewDelayingQueueWithCustomClock(clock.RealClock{}, name)
@@ -46,8 +52,12 @@ func NewNamedDelayingQueue(name string) DelayingInterface {
4652
// NewDelayingQueueWithCustomClock constructs a new named workqueue
4753
// with ability to inject real or fake clock for testing purposes
4854
func NewDelayingQueueWithCustomClock(clock clock.Clock, name string) DelayingInterface {
55+
return newDelayingQueue(clock, NewNamed(name), name)
56+
}
57+
58+
func newDelayingQueue(clock clock.Clock, q Interface, name string) *delayingType {
4959
ret := &delayingType{
50-
Interface: NewNamed(name),
60+
Interface: q,
5161
clock: clock,
5262
heartbeat: clock.NewTicker(maxWait),
5363
stopCh: make(chan struct{}),
@@ -56,7 +66,6 @@ func NewDelayingQueueWithCustomClock(clock clock.Clock, name string) DelayingInt
5666
}
5767

5868
go ret.waitingLoop()
59-
6069
return ret
6170
}
6271

0 commit comments

Comments
 (0)