Skip to content

Get id of Bandwidth which has zero tokens #185

Discussion options

You must be logged in to vote

@dlakhtyuk

Yes, it is possible. There is Verbose API for doing stuff like this. It is not well documented on the Github Readme Pages, but I believe that javadocs is good enough.

According to your particular task Verbose API can be used in following way:

        Bucket bucket = Bucket4j.builder()
                .addLimit(Bandwidth.simple(10, Duration.ofSeconds(1)).withId("technical-limit"))
                .addLimit(Bandwidth.simple(10000, Duration.ofHours(1)).withId("business-limit"))
                .build();
        ...
        int tokensToConsume = 100;
        VerboseResult<Boolean> verboseResult = bucket.asVerbose().tryConsume(tokensToConsume);
        boolean wasConsumed = verboseR…

Replies: 3 comments 5 replies

Comment options

You must be logged in to vote
1 reply
@dlakhtyuk
Comment options

Answer selected by dlakhtyuk
Comment options

You must be logged in to vote
3 replies
@dlakhtyuk
Comment options

@dlakhtyuk
Comment options

@vladimir-bukhtoyarov
Comment options

Comment options

You must be logged in to vote
1 reply
@dlakhtyuk
Comment options

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