Workqueue: Add generic versions that are properly typed

This change adds a generic version of the various workqueue types while
retaining compatibility for the existing exported symbols and constructors.
The generic variants are prefixed with `Typed` and the existing ones are
marked as deprecated to nudge people to transition without breaking
them.

Kubernetes-commit: 0c7370bb851c15825d30a516722139ccccca0cfc
This commit is contained in:
Alvaro Aleman
2024-04-11 18:11:41 -04:00
committed by Kubernetes Publisher
parent 9433226579
commit d67dddfe90
8 changed files with 270 additions and 131 deletions

View File

@@ -25,17 +25,17 @@ import (
func TestRateLimitingQueue(t *testing.T) {
limiter := NewItemExponentialFailureRateLimiter(1*time.Millisecond, 1*time.Second)
queue := NewRateLimitingQueue(limiter).(*rateLimitingType)
queue := NewRateLimitingQueue(limiter).(*rateLimitingType[any])
fakeClock := testingclock.NewFakeClock(time.Now())
delayingQueue := &delayingType{
Interface: New(),
delayingQueue := &delayingType[any]{
TypedInterface: New(),
clock: fakeClock,
heartbeat: fakeClock.NewTicker(maxWait),
stopCh: make(chan struct{}),
waitingForAddCh: make(chan *waitFor, 1000),
metrics: newRetryMetrics("", nil),
}
queue.DelayingInterface = delayingQueue
queue.TypedDelayingInterface = delayingQueue
queue.AddRateLimited("one")
waitEntry := <-delayingQueue.waitingForAddCh