-
Notifications
You must be signed in to change notification settings - Fork 277
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
Add current bucket configuration to ConsumptionProbe #117
Conversation
* Override equals() and hashCode() in BucketConfiguration and Bandwidth * Fix warnings in POM * Add Maven Wrapper
@vladimir-bukhtoyarov I'm having a difficult time getting all of the Surefire tests to pass, either locally or in Travis CI. |
I will look |
Thanks @vladimir-bukhtoyarov. I'm running Travis CI on the
|
Hello @chipkillmar According to failed tests on Travis, I think it failed with little violation because of differences in thread parking on my machine and machine used by Travis, I will rewrite the test to be more stable. According to Maven Wrapper - it is useful feature, I will merge it. According to extension of VerboseResult<ConsumptionProbe> result = bucket.asVerbose().tryConsumeAndReturnRemaining(1);
ConsumptionProbe probe = result.getValue();
BucketConfiguration configuration = result.getConfiguration() And in addition, Thanks for your work, I am going to merge your request to the intermediate branch, but I will rollback changes in the ConsumptionProbe because of reason described above. I expect that I will have time to release new version with Verbose API at next weekend. |
Thanks @vladimir-bukhtoyarov! Your |
I have released Verbose API under the version |
Published to Maven Central just now.
@chipkillmar yes your help will be useful, if you have enough time, please add your case to documentation |
@vladimir-bukhtoyarov thanks for
bucket4j
!I'd like to open a pull request for a minor change to
ConsumptionProbe
.My use case is that I'd like to report the current bucket capacity in a custom HTTP header such as
X-Rate-Limit-Limit
after callingbucket.tryConsumeAndReturnRemaining(numberOfTokens)
.I'm using a Hazelcast distributed map whose configuration might be replaced often at runtime, along with a single simple bandwidth bucket configuration. I'd like to be able to report the exact bucket capacity at the time of consumption, without having to track the bucket configuration on each cluster member.
I also overrode
equals()
andhashCode()
on theBucketConfiguration
andBandwidth
classes, as I believe this makes it easier to test configurations for equality (I'm using an external utility method for this now).Other minor changes here include adding explicit versions for Maven plugins to the parent POM, in order to fix some warnings, and adding the Takari Maven Wrapper, which I'm a fan of.
Thanks in advance for your feedback.