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

tower::limit::RateLimit and series of query #454

Closed
IamFake opened this issue May 24, 2020 · 3 comments
Closed

tower::limit::RateLimit and series of query #454

IamFake opened this issue May 24, 2020 · 3 comments

Comments

@IamFake
Copy link

IamFake commented May 24, 2020

When i'm wrapping my object with RateLimit object and with 1 times per 1 second limit, and then call it 6 times - i've got 6 calls to poll_ready func and only 2 calls to "call" func.

It's happen becouse in poll_ready we have following code

State::Limited(ref mut sleep) => { ready!(Pin::new(sleep).poll(cx)); }

and in this case "sleep" knows only context of the "last" query called for poll_ready, so 4 other queries won't be woked up (as i suppose).

@seanmonstar
Copy link
Collaborator

This is expected behavior. What are you doing with the requests that are "over limit"? Rejecting them immediately, or just collecting them to pass on once allowed?

If the latter, you can combine with tower-buffer to do exactly that.

@IamFake
Copy link
Author

IamFake commented May 24, 2020

Hm, that's not obvious. I want them to pass on once allowed. Ok, thanks, I will try tower-buffer to solve that.

@IamFake IamFake closed this as completed May 24, 2020
@seanmonstar
Copy link
Collaborator

As part of #431, we should improve the docs of that.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants