From 1ded602dc06c0ae7c7f8add80eb8ed0ec302217e Mon Sep 17 00:00:00 2001 From: fatedier Date: Mon, 23 Mar 2020 12:15:29 +0800 Subject: [PATCH] Export new constructor for DelayingQueue Kubernetes-commit: b5d989a6fc78fd8d1743eb2b80b9be4cb6e3c6ac --- util/workqueue/delaying_queue.go | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/util/workqueue/delaying_queue.go b/util/workqueue/delaying_queue.go index e1ab76ea..31d9182d 100644 --- a/util/workqueue/delaying_queue.go +++ b/util/workqueue/delaying_queue.go @@ -38,6 +38,12 @@ func NewDelayingQueue() DelayingInterface { return NewDelayingQueueWithCustomClock(clock.RealClock{}, "") } +// NewDelayingQueueWithCustomQueue constructs a new workqueue with ability to +// inject custom queue Interface instead of the default one +func NewDelayingQueueWithCustomQueue(q Interface, name string) DelayingInterface { + return newDelayingQueue(clock.RealClock{}, q, name) +} + // NewNamedDelayingQueue constructs a new named workqueue with delayed queuing ability func NewNamedDelayingQueue(name string) DelayingInterface { return NewDelayingQueueWithCustomClock(clock.RealClock{}, name) @@ -46,8 +52,12 @@ func NewNamedDelayingQueue(name string) DelayingInterface { // NewDelayingQueueWithCustomClock constructs a new named workqueue // with ability to inject real or fake clock for testing purposes func NewDelayingQueueWithCustomClock(clock clock.Clock, name string) DelayingInterface { + return newDelayingQueue(clock, NewNamed(name), name) +} + +func newDelayingQueue(clock clock.Clock, q Interface, name string) *delayingType { ret := &delayingType{ - Interface: NewNamed(name), + Interface: q, clock: clock, heartbeat: clock.NewTicker(maxWait), stopCh: make(chan struct{}), @@ -56,7 +66,6 @@ func NewDelayingQueueWithCustomClock(clock clock.Clock, name string) DelayingInt } go ret.waitingLoop() - return ret }