Skip to content
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 RateLimiter to List iter functions. #485

Open
nathanhack opened this issue Dec 24, 2024 · 0 comments
Open

Add RateLimiter to List iter functions. #485

nathanhack opened this issue Dec 24, 2024 · 0 comments
Labels
enhancement New feature or request

Comments

@nathanhack
Copy link

nathanhack commented Dec 24, 2024

Is your feature request related to a problem? Please describe.
Currently when using a List function it provides no way to mitigate rate limit errors.

Describe the solution you'd like
Ideally a way to rate limit requests. It could be achieved by passing in a ratelimiter interface to the function either as a new function parameter, in params, or as an option.

type RateLimiter interface{
     Take()
}

Given the current interface I would claim creating a new ratelimiter option is the cleanest/easiest way.

Describe alternatives you've considered
Currently the only way to incorporate a rate limiter is before the initial List function and then before the iter.Next() function is called. But in a concurrent application this is insufficient.

ratelimiter.Take()
iter := c.ListAggs(context.TODO(), params, opts...)
for iter.Next() {
	log.Print(iter.Item()) // do something with the current value
        ratelimiter.Take()
}
@nathanhack nathanhack added the enhancement New feature or request label Dec 24, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

1 participant