-
Notifications
You must be signed in to change notification settings - Fork 0
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add Rate limiter #579
Add Rate limiter #579
Conversation
pkg/ratelimiter/interfaces.go
Outdated
type RateLimiter interface { | ||
// When gets an item and gets to decide how long that item should wait | ||
When(item interface{}) time.Duration | ||
// Forget indicates that an item is finished being retried. Doesn't matter whether it's for failing | ||
// or for success, we'll stop tracking it | ||
Forget(item interface{}) | ||
// NumRequeues returns back how many failures the item has had | ||
NumRequeues(item interface{}) int | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What is the point of duplicating the controller.RateLimiter
interface? If you want to avoid using the controller
package prefix, you can just create an alias for it type RateLimiter = controller.RateLimiter
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
For now, there is no use for duplicating it. I probably remove it.
pkg/ratelimiter/rate_limiter.go
Outdated
func NewItemExponentialFailureRateLimiterWithMaxTries(baseDelay time.Duration, maxDelay time.Duration) RateLimiter { | ||
return &ItemExponentialFailureRateLimiterWithMaxTries{ | ||
failures: map[interface{}]int{}, | ||
baseDelay: baseDelay, | ||
maxDelay: maxDelay, | ||
maxTries: defaultMaxTries, | ||
} | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think it would be better if there was an opportunity to configure maxRetries
myself. If it is not configured then set defaultMaxTries
value
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not sure about the idea of configuring the maxTries
. I think it's more of a generic thing. But let's get another opinion about this.
065d65d
to
25fad97
Compare
ref #559
Custom Rate Limiter (CRL) with several features:
CRL is built on the
controller-runtime
framework. For the CRL proper work, all controllers, in case of an error, should now return errors, instead ofnil
.Refactored the Cassandra controller, for the CRL's capabilities and suits as an example for further refactoring and CRL integration.
ReconcileReque60
now works only in case of possible Kubernetes error.