Skip to content

Commit

Permalink
Add a comment on using the next pull second
Browse files Browse the repository at this point in the history
Follows up #58 with a clarifying comment.
  • Loading branch information
brandur committed Aug 6, 2022
1 parent 608c454 commit b45e883
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -63,11 +63,13 @@ impl Command for ThrottleCommand {

let (throttled, rate_limit_result) = limiter.rate_limit(key, quantity)?;

// If either time had a partial component, but it up to the next full
// second because otherwise a fast-paced caller could try again too
// early.
let mut retry_after = rate_limit_result.retry_after.num_seconds();
if rate_limit_result.retry_after.num_milliseconds() > 0 {
retry_after += 1
}

let mut reset_after = rate_limit_result.reset_after.num_seconds();
if rate_limit_result.reset_after.num_milliseconds() > 0 {
reset_after += 1
Expand Down

0 comments on commit b45e883

Please sign in to comment.