java.lang.Object
io.github.bucket4j.local.LocalBucketBuilder
This builder creates in-memory buckets (
LockFreeBucket).-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionAdds limited bandwidth for all buckets which will be constructed by this builder.addLimit(Function<BandwidthBuilder.BandwidthBuilderCapacityStage, BandwidthBuilder.BandwidthBuilderBuildStage> bandwidthConfigurator) build()Constructs the bucket.withCustomTimePrecision(TimeMeter customTimeMeter) SpecifiescustomTimeMetertime meter for buckets that will be created by this builder.withListener(BucketListener listener) Specifieslistenerfor buckets that will be created by this builder.SpecifiesTimeMeter.SYSTEM_MILLISECONDSas time meter for buckets that will be created by this builder.SpecifiesTimeMeter.SYSTEM_NANOTIMEas time meter for buckets that will be created by this builder.withSynchronizationStrategy(SynchronizationStrategy synchronizationStrategy) SpecifiessynchronizationStrategyfor buckets that will be created by this builder.
-
Constructor Details
-
LocalBucketBuilder
public LocalBucketBuilder()
-
-
Method Details
-
addLimit
Adds limited bandwidth for all buckets which will be constructed by this builder.- Parameters:
bandwidth- limitation- Returns:
- this builder instance
-
addLimit
public LocalBucketBuilder addLimit(Function<BandwidthBuilder.BandwidthBuilderCapacityStage, BandwidthBuilder.BandwidthBuilderBuildStage> bandwidthConfigurator) -
withNanosecondPrecision
SpecifiesTimeMeter.SYSTEM_NANOTIMEas time meter for buckets that will be created by this builder.- Returns:
- this builder instance
-
withMillisecondPrecision
SpecifiesTimeMeter.SYSTEM_MILLISECONDSas time meter for buckets that will be created by this builder.- Returns:
- this builder instance
-
withCustomTimePrecision
SpecifiescustomTimeMetertime meter for buckets that will be created by this builder.- Parameters:
customTimeMeter- object which will measure time.- Returns:
- this builder instance
-
withSynchronizationStrategy
public LocalBucketBuilder withSynchronizationStrategy(SynchronizationStrategy synchronizationStrategy) SpecifiessynchronizationStrategyfor buckets that will be created by this builder.- Parameters:
synchronizationStrategy- the strategy of synchronization which need to be applied to prevent data-races in multi-threading usage scenario.- Returns:
- this builder instance
-
withListener
Specifieslistenerfor buckets that will be created by this builder.- Parameters:
listener- the listener of bucket events.- Returns:
- this builder instance
-
build
Constructs the bucket.- Returns:
- the new bucket
-