Skip to content

Commit b3885e6

Browse files
mergencisergenyalcin
authored andcommitted
Replace deprecated API with typed versions.
References: kubernetes/kubernetes#124263 kubernetes-sigs/controller-runtime#2799 Signed-off-by: Cem Mergenci <cmergenci@gmail.com>
1 parent a514684 commit b3885e6

1 file changed

Lines changed: 9 additions & 9 deletions

File tree

pkg/controller/handler/eventhandler.go

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -23,8 +23,8 @@ const NoRateLimiter = ""
2323
// objects and allows upjet components to queue reconcile requests.
2424
type EventHandler struct {
2525
innerHandler handler.EventHandler
26-
queue workqueue.RateLimitingInterface
27-
rateLimiterMap map[string]workqueue.RateLimiter
26+
queue workqueue.TypedRateLimitingInterface[reconcile.Request]
27+
rateLimiterMap map[string]workqueue.TypedRateLimiter[reconcile.Request]
2828
logger logging.Logger
2929
mu *sync.RWMutex
3030
}
@@ -44,7 +44,7 @@ func NewEventHandler(opts ...Option) *EventHandler {
4444
eh := &EventHandler{
4545
innerHandler: &handler.EnqueueRequestForObject{},
4646
mu: &sync.RWMutex{},
47-
rateLimiterMap: make(map[string]workqueue.RateLimiter),
47+
rateLimiterMap: make(map[string]workqueue.TypedRateLimiter[reconcile.Request]),
4848
}
4949
for _, o := range opts {
5050
o(eh)
@@ -70,7 +70,7 @@ func (e *EventHandler) RequestReconcile(rateLimiterName, name string, failureLim
7070
if rateLimiterName != NoRateLimiter {
7171
rateLimiter := e.rateLimiterMap[rateLimiterName]
7272
if rateLimiter == nil {
73-
rateLimiter = workqueue.DefaultControllerRateLimiter()
73+
rateLimiter = workqueue.DefaultTypedControllerRateLimiter[reconcile.Request]()
7474
e.rateLimiterMap[rateLimiterName] = rateLimiter
7575
}
7676
if failureLimit != nil && rateLimiter.NumRequeues(item) > *failureLimit {
@@ -100,33 +100,33 @@ func (e *EventHandler) Forget(rateLimiterName, name string) {
100100
})
101101
}
102102

103-
func (e *EventHandler) setQueue(limitingInterface workqueue.RateLimitingInterface) {
103+
func (e *EventHandler) setQueue(limitingInterface workqueue.TypedRateLimitingInterface[reconcile.Request]) {
104104
e.mu.Lock()
105105
defer e.mu.Unlock()
106106
if e.queue == nil {
107107
e.queue = limitingInterface
108108
}
109109
}
110110

111-
func (e *EventHandler) Create(ctx context.Context, ev event.CreateEvent, limitingInterface workqueue.RateLimitingInterface) {
111+
func (e *EventHandler) Create(ctx context.Context, ev event.CreateEvent, limitingInterface workqueue.TypedRateLimitingInterface[reconcile.Request]) {
112112
e.setQueue(limitingInterface)
113113
e.logger.Debug("Calling the inner handler for Create event.", "name", ev.Object.GetName(), "queueLength", limitingInterface.Len())
114114
e.innerHandler.Create(ctx, ev, limitingInterface)
115115
}
116116

117-
func (e *EventHandler) Update(ctx context.Context, ev event.UpdateEvent, limitingInterface workqueue.RateLimitingInterface) {
117+
func (e *EventHandler) Update(ctx context.Context, ev event.UpdateEvent, limitingInterface workqueue.TypedRateLimitingInterface[reconcile.Request]) {
118118
e.setQueue(limitingInterface)
119119
e.logger.Debug("Calling the inner handler for Update event.", "name", ev.ObjectOld.GetName(), "queueLength", limitingInterface.Len())
120120
e.innerHandler.Update(ctx, ev, limitingInterface)
121121
}
122122

123-
func (e *EventHandler) Delete(ctx context.Context, ev event.DeleteEvent, limitingInterface workqueue.RateLimitingInterface) {
123+
func (e *EventHandler) Delete(ctx context.Context, ev event.DeleteEvent, limitingInterface workqueue.TypedRateLimitingInterface[reconcile.Request]) {
124124
e.setQueue(limitingInterface)
125125
e.logger.Debug("Calling the inner handler for Delete event.", "name", ev.Object.GetName(), "queueLength", limitingInterface.Len())
126126
e.innerHandler.Delete(ctx, ev, limitingInterface)
127127
}
128128

129-
func (e *EventHandler) Generic(ctx context.Context, ev event.GenericEvent, limitingInterface workqueue.RateLimitingInterface) {
129+
func (e *EventHandler) Generic(ctx context.Context, ev event.GenericEvent, limitingInterface workqueue.TypedRateLimitingInterface[reconcile.Request]) {
130130
e.setQueue(limitingInterface)
131131
e.logger.Debug("Calling the inner handler for Generic event.", "name", ev.Object.GetName(), "queueLength", limitingInterface.Len())
132132
e.innerHandler.Generic(ctx, ev, limitingInterface)

0 commit comments

Comments
 (0)