Replies: 3 comments 1 reply
-
Hello @HaloFour In the scope of #117 it was especially decided to not provide In general it is not a big deal to implement the both |
Beta Was this translation helpful? Give feedback.
-
After thinking more I decided to implement such feature #483. I have changed my mind because released that, the main purpuse of VerboseResult is providing the answer why any method returns concrete result. Providing most fresh snapshot is not a goal, so it nothing wrong to return Snapshot that can be obsolete at return time. |
Beta Was this translation helpful? Give feedback.
-
Since Duration maxWait = Duration.ofMillis(10);
VerboseResult<Boolean> tryConsumeResponse = bucket.asBlocking().asVerbose().tryConsume(1, maxWait);
boolean wasConsumed = tryConsumeResponse.getValue();
if (wasConsumed) {
// do something
} else {
// do something else
} |
Beta Was this translation helpful? Give feedback.
-
I'm using the
VerboseBucket
interface to calltryConsume
in my Spring service for rate limiting, so that I can accurately report the remaining tokens in metrics. I am interested in using the overload oftryConsume
that accepts a wait time so that I can introduce a short delay when out of tokens but I noticed that these overloads aren't available throughVerboseBucket
. I'd like to be able to report both the remaining tokens, if available, as well as the delay time, if necessary. There is the verbose implementation ofestimateAbilityToConsume
, but there isn't a thread-safe way to report that information and consume the tokens.Is there any interest in adding this API? I'd be happy to contribute it.
Edit: I imagine it might be more appropriate to expand
tryConsumeAndReturnRemaining
so that it supports a wait time, given it already seems to handle the rest and does have a "verbose" version as well?Beta Was this translation helpful? Give feedback.
All reactions