-
Notifications
You must be signed in to change notification settings - Fork 43
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 periodic/Doer for frequency-limited action execution #220
Add periodic/Doer for frequency-limited action execution #220
Conversation
logp/ratelimited.go
Outdated
|
||
// RateLimitedLogger is a logger that limits log messages to once within a | ||
// specified period. | ||
// It is intended for logging events that occur frequently, providing a summary |
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.
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.
There is a custom implementation of the token bucket algorithm in https://github.com/elastic/beats/blob/main/libbeat/processors/ratelimit/token_bucket.go but I'd honestly prefer we replace that the one in x/time/rate as well.
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.
well apart from the fact I missed there is a [Every](https://pkg.go.dev/golang.org/x/time/rate#Every)
, the work to accumulate the number of events to then log the summary would be the same. Also using the ticker it's a rather straight forward implementation. Thus I don't find it necessary to use https://pkg.go.dev/golang.org/x/time/rate
010244f
to
b4dcc44
Compare
86dc65c
to
e391dbc
Compare
@AndersonQ shouldn't we also change the PR title? |
I did, but didn't click on 'save' ahah. Now it's fixed, thanks |
5537a8f
to
b2fd3b3
Compare
The Doer limits the execution of an action to at most once within a specified period. It's designed for managing frequent events by providing a summary with the number of occurrences within the given period. If no event happen, the action is not executed.
b2fd3b3
to
456505c
Compare
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 thread-safe.
💚 Build Succeeded
History
cc @AndersonQ |
What does this PR do?
Add
periodic/Doer
for frequency-limited action executionWhy is it important?
The Doer limits the execution of an action to at most once within a specified period. It's designed for managing frequent events by providing a summary with the number of occurrences within the given period. If no event happen, the action is not executed.
Checklist
Related issues