Skip to content

RateLimit-Reset Header : getting time to wait for refill even limit is not exceeded #197

Discussion options

You must be logged in to vote

@xavier-b

Hello, ConsumptionProbe#getNanosToWaitForRefill has nothing in common with RateLimit-Reset. As mentioned in the javadocs, it returns the time required to refill requested amount of tokens, not the time required to refill tokens up to max possible values.

To get such information you need to use Verbose API:

VerboseResult<ConsumptionProbe> result = bucket.asVerbose().tryConsumeAndReturnRemaining(1);
ConsumptionProbe probe = result.getValue();
Diagnostics diagnostics = result.getDiagnostics();
if (probe.isConsumed()) {
    long nanosToRefillUpToLimit = diagnostics.calculateFullRefillingTime();
    ...
} else {
    long nanosToRefillUpToLimit = diagnostics.calculateFullRefillingTime(…

Replies: 1 comment 2 replies

Comment options

You must be logged in to vote
2 replies
@xavier-b
Comment options

@vladimir-bukhtoyarov
Comment options

Answer selected by vladimir-bukhtoyarov
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants
Converted from issue

This discussion was converted from issue #196 on December 02, 2021 05:22.