Minor or cosmetic changes have been omitted from this list. See https://github.com/cowwoc/token-bucket/commits/master for a full list.
- Breaking changes
Limit.builder()
replaced byBucket.builder().addLimit()
.- Removed
AbstractContainer.getParent()
. - Removed
Container.userDataInToString()
.
- Improvements
- Performance improvement: Upgraded to Requirements 8.0.1 to which improves the performance of
assertThat()
. - Added
ConsumptionResult.getTokensLeft()
.
- Performance improvement: Upgraded to Requirements 8.0.1 to which improves the performance of
- Bug fixes
- Threads were not sleeping if the duration was less than 1 second.
- Refill wasn't working properly unless
maxTokens
was a multiple ofrefillSize
. ConfigurationUpdater
wasn't updating all the necessary fields onclose()
.
- Improvements
- Replaced references to a 3rd-party
@CheckReturnValue
annotation with a local copy. - Added ability to remove
userData
from output oftoString()
because it can be very noisy. SeeBuilder.userDataInToString()
. - Removed
@CheckReturnValue
fromContainer.consume()
andconsume(tokens)
because the number of tokens that are consumed is known in advance. - Added
toString()
to allBuilder
/ConfigurationUpdater
classes.- Added
ConfigurationUpdater.toString()
.
- Added
- Performance improvement: Group 3+ assertions behind assertionsAreEnabled() to reduce garbage creation.
- Replaced references to a 3rd-party
- Bug fixes:
ContainerList.ConfigurationUpdater.close()
was not validating the updated children.
- Improvements
- There is no way to fix a
ConfigurationUpdater
oncetry-with-resources
exits, so now the updater is closed and write-lock released even if an exception is thrown.
- There is no way to fix a
- Breaking changes:
- Renamed
Container.consume(tokens, timeout, unit)
toContainer.tryConsume(tokens, timeout, unit)
. - Renamed
Container.consume(minimumTokens, maximumTokens, timeout, unit)
toContainer.tryConsume(minimumTokens, maximumTokens, timeout, unit)
.
- Renamed
- Improvements
- Improved performance of Limit.refill().
- Container tryConsume() does not wait if
timeout
is zero.
- Bugfixes
Bucket.tryConsume()
sometimes returnedlongestDelay.getTokensConsumed() > 0
even thoughtokensConsumed == 0
.
- Improvements
- Added
ConsumptionResult.getConsumedAt()
which denotes the time at which an attempt was made to consume tokens. This differs fromgetRequestedAt()
in thatgetConsumedAt()
is set after acquiring a
write-lock. ConsumptionResult.getAvailableAt()
will be equal togetConsumedAt()
if tokens were consumed, instead ofgetRequestedAt()
.
- Added
- Bugfixes
- Documentation typo:
ConsumptionResult.getContainer()
returns "the lowest common ancestor", not "the highest common ancestor". - Containers that used the same
SelectionPolicy
would corrupt each other's state. SelectionPolicy
was selecting non-existent children if the number of children in the container was reduced.ContainerList.ConfigurationUpdater.consumeFromOne(), consumeFromAll()
did not updateselectionPolicy
.
- Documentation typo:
-
Breaking changes:
- Bucket
Builder
/ConfigurationUpdater.getLimits()
returns a List instead of a Set.
- ConsumptionResult
- Renamed
bottleneck
tobottlenecks
.
- Renamed
- Renamed
SelectionPolicy.roundRobin()
toSelectionPolicy.ROUND_ROBIN
. Limit/Bucket/ContainerList.updateConfiguration()
now holds a lock until the update is applied.- Removed
Limit.ConfigurationUpdater.lastRefilledAt/startOfCurrentPeriod/tokensAddedInCurrentPeriod
. - Updating a Limit starts a new period.
- Removed
Bucket.addTokens()
(waiting for someone to bring up a justifying use-case).
- Bucket
-
New features
- Added
ContainerListener
used to listen to Container events. - Added
Bucket.getLimitWithLowestRefillRate()
.
- Added
-
Improvements
ContainerList/Bucket/Limit.toString()
now shows properties on different lines.
-
Bugfixes
Limit.refill()
calculation error caused tokensAddedInCurrentPeriod to surpass tokensPerPeriod.Limit/Bucket/ContainerList.updateConfiguration()
no longer updates the bucket's position in the parent's list.
- Breaking changes:
- Limits
- Renamed
tokensAvailable
toavailableTokens
. - Renamed
maxTokens
tomaximumTokens
. - Renamed
minimumToRefill
tominimumRefill
. - Renamed
minimumRefill
torefillSize
.
- Renamed
- Bucket
- Retain insertion order of limits.
- Container
- Renamed
consumeRange()
toconsume()
. - Disallow consumption of zero tokens.
- Renamed
- ConsumptionResult
- Renamed
getTokensAvailableAt()
togetAvailableAt()
. - Renamed
getTokensAvailableIn()
togetAvailableIn()
.
- Renamed
- Limits
- New features
- Ability to look up existing values from
Builder
,ConfigurationUpdater
classes. - Ability to navigate from a
Limit
to itsBucket
and aContainer
to its parent. - Added
ConsumptionResult.getBottleneck()
which returns the list of Limits that are preventing consumption.
- Ability to look up existing values from
- Improvements:
- Don't wake up consumers unless the number of tokens is positive.
- Allow negative
Limit.initialTokens
,availableTokens
.
- Bugfixes:
ContainerList.updateConfiguration()
was not updating the consumption policy.
- Breaking changes:
- Added
Limit.builder()
,Bucket.builder()
,ContainerList.builder()
. try/consume()
returnsConsumptionResult
instead of aboolean
.
- Added
- New features:
- Ability to consume tokens from a container that contains one or more buckets.
- Ability to consume a variable number of tokens using
try/consumeRange(minimumTokens, maximumTokens)
.
- Bugfix:
maxTokens
may be equal totokensPerPeriod
orinitialTokens
.
- Initial release