Interface FixedLimitConfig
- All Superinterfaces:
Prototype.Api, Prototype.Factory<FixedLimit>
- All Known Implementing Classes:
FixedLimitConfig.BuilderBase.FixedLimitConfigImpl
-
Nested Class Summary
Nested ClassesModifier and TypeInterfaceDescriptionstatic classFluent API builder forFixedLimit.static classFixedLimitConfig.BuilderBase<BUILDER extends FixedLimitConfig.BuilderBase<BUILDER, PROTOTYPE>, PROTOTYPE extends FixedLimitConfig>Fluent API builder base forFixedLimitConfig. -
Method Summary
Modifier and TypeMethodDescriptionstatic FixedLimitConfig.Builderbuilder()Create a new fluent API builder to customize configuration.static FixedLimitConfig.Builderbuilder(FixedLimitConfig instance) Create a new fluent API builder from an existing instance.clock()A clock that supplies nanosecond time.static FixedLimitConfigcreate()Create a new instance with default values.static FixedLimitConfigCreate a new instance from configuration.booleanWhether to collect metrics for the fixed limit implementation.booleanfair()Whether theSemaphoreshould beSemaphore.isFair().name()Name of this instance.intpermits()Number of permits to allow.intHow many requests can be enqueued waiting for a permit.How long to wait for a permit when enqueued.Explicitly configured semaphore.Methods inherited from interface Prototype.Factory
buildModifier and TypeMethodDescriptionbuild()Create a new instance of the runtime type from this config object.
-
Method Details
-
builder
Create a new fluent API builder to customize configuration.- Returns:
- a new builder
-
builder
Create a new fluent API builder from an existing instance.- Parameters:
instance- an existing instance used as a base for the builder- Returns:
- a builder based on an instance
-
create
Create a new instance from configuration.- Parameters:
config- used to configure the new instance- Returns:
- a new instance configured from configuration
-
create
-
permits
int permits()Number of permits to allow. Defaults to 0. When set to0, we switch to unlimited.- Returns:
- number of permits
-
fair
boolean fair()- Returns:
- whether this should be a fair semaphore
-
queueLength
int queueLength()How many requests can be enqueued waiting for a permit. Note that this may not be an exact behavior due to concurrent invocations. We useSemaphore.getQueueLength()in theFixedLimitimplementation. Default value is 0. If set to0, there is no queueing.- Returns:
- number of requests to enqueue
-
queueTimeout
-
name
-
semaphore
-
clock
A clock that supplies nanosecond time.- Returns:
- supplier of current nanoseconds, defaults to
System.nanoTime()
-
enableMetrics
boolean enableMetrics()Whether to collect metrics for the fixed limit implementation.- Returns:
- metrics flag
-