Trying to configure an existing bucket #438
Unanswered
AmitLustiger
asked this question in
Q&A
Replies: 1 comment 7 replies
-
proxyManager.builder().withImplicitConfigurationReplacement(2, TokensInheritanceStrategy.PROPORTIONALLY).
build(key, configSupplier)
.getAvailableTokens();
Just build bucket, and reconfigure it, bucket-proxy is lazy, there is no double interraction with storage. |
Beta Was this translation helpful? Give feedback.
7 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
Hey there!
I'm having a problem with overriding a bucket by key.
I use 2 API's in my code.
The first tries to consume a token from a bucket by key, and if there is no bucket exists for that key, a new Bucket is created with default Bandwidth values (hardcoded).
Supplier configSupplier = getConfigSupplier();
return proxyManager.builder().build(key, configSupplier);
}
The 2nd allows to change the configuration of an existing bucket.
For example, if I created a bucket with the first API with the key "key1" and now I use the 2nd API to reconfigure and replace the bucket created with:
Bucket newBucket = proxyManager.builder().withImplicitConfigurationReplacement(1, TokensInheritanceStrategy.PROPORTIONALLY).
build(key, newBucketConfiguration);
where key = "key1"
When I try to use the first API again to tryConsume a token from the bucket, the bucket is still the original one.
(I debugged it and saw that the Configuration is the same).
I saw in the documentation that we need to use withImplicitConfigurationReplacement in order to change it.
I also tried replacing the following line in the first API:
To
proxyManager.builder().withImplicitConfigurationReplacement(2, TokensInheritanceStrategy.PROPORTIONALLY).
build(key, configSupplier);
Also,
I saw that there is a solution using ** replaceConfiguration**.
But that method is supposed to be performed on an object of type Bucket.
How can I get my bucket using its key?
ProxyManager supplies only getProxyConfiguration method that returns BucketConfiguration object.
Thank you!
Beta Was this translation helpful? Give feedback.
All reactions