Use generics for waitFor (delaying workqueue) in client-go

With this change, we can typically avoid an extra heap allocation when
calling AddAfter with a positive duration (which causes the creation of
a waitFor object). This is because workqueues are typically used with
string keys, and casting a string (or more generally, non-pointer types)
to an `interface{}` will cause an heap escape / allocation.

Ater this change, there is no longer any usage of `type t interface{}`,
which was creating some confusion after the switch to generics in the
workqueue package.

Co-authored-by: Quan Tian <quan.tian@broadcom.com>
Signed-off-by: Antonin Bas <antonin.bas@broadcom.com>

Kubernetes-commit: 53ddffb55709857fec6bddbd5ca4ca1b03f7da97
This commit is contained in:
Antonin Bas
2024-10-08 15:12:11 -07:00
committed by Kubernetes Publisher
parent ba20fcad8f
commit 3c28f81659
5 changed files with 25 additions and 25 deletions

View File

@@ -32,7 +32,7 @@ func TestRateLimitingQueue(t *testing.T) {
clock: fakeClock,
heartbeat: fakeClock.NewTicker(maxWait),
stopCh: make(chan struct{}),
waitingForAddCh: make(chan *waitFor, 1000),
waitingForAddCh: make(chan *waitFor[any], 1000),
metrics: newRetryMetrics("", nil),
}
queue.TypedDelayingInterface = delayingQueue