Skip to content

Commit

Permalink
Merge pull request #505 from rramkumar1/master
Browse files Browse the repository at this point in the history
Allow for setting the rate limiter on the work queue
  • Loading branch information
k8s-ci-robot authored Oct 1, 2018
2 parents 1795e84 + 9336c8c commit a3518ea
Showing 1 changed file with 9 additions and 3 deletions.
12 changes: 9 additions & 3 deletions pkg/utils/taskqueue.go
Original file line number Diff line number Diff line change
Expand Up @@ -98,13 +98,19 @@ func (t *PeriodicTaskQueue) worker() {
}
}

// NewPeriodicTaskQueue creates a new task queue with the given sync function.
// The sync function is called for every element inserted into the queue.
// NewPeriodicTaskQueue creates a new task queue with the default rate limiter.
func NewPeriodicTaskQueue(resource string, syncFn func(string) error) *PeriodicTaskQueue {
rl := workqueue.DefaultControllerRateLimiter()
return NewPeriodicTaskQueueWithLimiter(resource, syncFn, rl)
}

// NewPeriodicTaskQueueWithLimiter creates a new task queue with the given sync function
// and rate limiter. The sync function is called for every element inserted into the queue.
func NewPeriodicTaskQueueWithLimiter(resource string, syncFn func(string) error, rl workqueue.RateLimiter) *PeriodicTaskQueue {
return &PeriodicTaskQueue{
resource: resource,
keyFunc: KeyFunc,
queue: workqueue.NewRateLimitingQueue(workqueue.DefaultControllerRateLimiter()),
queue: workqueue.NewRateLimitingQueue(rl),
sync: syncFn,
workerDone: make(chan struct{}),
}
Expand Down

0 comments on commit a3518ea

Please sign in to comment.