@@ -38,6 +38,12 @@ func NewDelayingQueue() DelayingInterface {
38
38
return NewDelayingQueueWithCustomClock (clock.RealClock {}, "" )
39
39
}
40
40
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
+
41
47
// NewNamedDelayingQueue constructs a new named workqueue with delayed queuing ability
42
48
func NewNamedDelayingQueue (name string ) DelayingInterface {
43
49
return NewDelayingQueueWithCustomClock (clock.RealClock {}, name )
@@ -46,8 +52,12 @@ func NewNamedDelayingQueue(name string) DelayingInterface {
46
52
// NewDelayingQueueWithCustomClock constructs a new named workqueue
47
53
// with ability to inject real or fake clock for testing purposes
48
54
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 {
49
59
ret := & delayingType {
50
- Interface : NewNamed ( name ) ,
60
+ Interface : q ,
51
61
clock : clock ,
52
62
heartbeat : clock .NewTicker (maxWait ),
53
63
stopCh : make (chan struct {}),
@@ -56,7 +66,6 @@ func NewDelayingQueueWithCustomClock(clock clock.Clock, name string) DelayingInt
56
66
}
57
67
58
68
go ret .waitingLoop ()
59
-
60
69
return ret
61
70
}
62
71
0 commit comments