Use the generic/typed workqueue throughout

This change makes us use the generic workqueue throughout the project in
order to improve type safety and readability of the code.
This commit is contained in:
Alvaro Aleman
2024-04-28 18:26:18 +02:00
parent d387c0c903
commit 6d0ac8c561
94 changed files with 830 additions and 603 deletions

View File

@@ -123,7 +123,7 @@ type DaemonSetsController struct {
nodeStoreSynced cache.InformerSynced
// DaemonSet keys that need to be synced.
queue workqueue.RateLimitingInterface
queue workqueue.TypedRateLimitingInterface[string]
failedPodsBackoff *flowcontrol.Backoff
}
@@ -153,7 +153,12 @@ func NewDaemonSetsController(
},
burstReplicas: BurstReplicas,
expectations: controller.NewControllerExpectations(),
queue: workqueue.NewNamedRateLimitingQueue(workqueue.DefaultControllerRateLimiter(), "daemonset"),
queue: workqueue.NewTypedRateLimitingQueueWithConfig(
workqueue.DefaultTypedControllerRateLimiter[string](),
workqueue.TypedRateLimitingQueueConfig[string]{
Name: "daemonset",
},
),
}
daemonSetInformer.Informer().AddEventHandler(cache.ResourceEventHandlerFuncs{
@@ -315,7 +320,7 @@ func (dsc *DaemonSetsController) processNextWorkItem(ctx context.Context) bool {
}
defer dsc.queue.Done(dsKey)
err := dsc.syncHandler(ctx, dsKey.(string))
err := dsc.syncHandler(ctx, dsKey)
if err == nil {
dsc.queue.Forget(dsKey)
return true