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

ratelimit: add method to retrieve the next refill time #124

Merged
merged 1 commit into from
Oct 31, 2024

Conversation

cgzones
Copy link
Contributor

@cgzones cgzones commented Oct 31, 2024

Useful to check whether the rate limiter has been is use in the recent past, e.g. to drop obsolete per client rate limiters.

p.s.:

cargo clippy currently fails for me due to:

error: written amount is not handled
   --> awaken/src/lib.rs:103:19
    |
103 |             match (&self.inner).write(&[1, 0, 0, 0, 0, 0, 0, 0]) {
    |                   ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
    |
    = help: use `Write::write_all` instead, or handle partial writes
note: the result is consumed here, but the amount of I/O bytes remains unhandled
   --> awaken/src/lib.rs:104:17
    |
104 |                 Ok(_) => Ok(()),
    |                 ^^^^^
    = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#unused_io_amount
    = note: `#[deny(clippy::unused_io_amount)]` on by default

error: written amount is not handled
   --> awaken/src/lib.rs:119:19
    |
119 |             match (&self.inner).write(&[0, 0, 0, 0, 0, 0, 0, 0]) {
    |                   ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
    |
    = help: use `Write::write_all` instead, or handle partial writes
note: the result is consumed here, but the amount of I/O bytes remains unhandled
   --> awaken/src/lib.rs:120:17
    |
120 |                 Ok(_) => Ok(()),
    |                 ^^^^^
    = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#unused_io_amount

error: could not compile `awaken` (lib) due to 2 previous errors

Useful to check whether the rate limiter has been is use in the recent
past, e.g. to drop obsolete per client rate limiters.
@brayniac
Copy link
Contributor

Thanks for opening this. I think this is a good addition. I'll open a separate issue for the clippy failures in awaken.

I'll cut a release after test complete and this is merged. Thank you again!

Copy link
Contributor

@brayniac brayniac left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM. Thank you!

@brayniac brayniac merged commit f0e3edc into pelikan-io:main Oct 31, 2024
15 checks passed
@brayniac
Copy link
Contributor

This is included in ratelimit v0.10.0 which is now live on crates.io. We appreciate the contribution!

@cgzones cgzones deleted the ratelimit_refill branch November 2, 2024 20:04
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

Successfully merging this pull request may close these issues.

2 participants