Class ThroughputLimitConfig.BuilderBase<BUILDER extends ThroughputLimitConfig.BuilderBase<BUILDER,PROTOTYPE>,PROTOTYPE extends ThroughputLimitConfig>
java.lang.Object
io.helidon.common.concurrency.limits.ThroughputLimitConfig.BuilderBase<BUILDER,PROTOTYPE>
- Type Parameters:
BUILDER- type of the builder extending this abstract builderPROTOTYPE- type of the prototype interface that would be built byPrototype.Builder.buildPrototype()
- All Implemented Interfaces:
Prototype.Builder<BUILDER,,PROTOTYPE> ConfigBuilderSupport.ConfiguredBuilder<BUILDER,,PROTOTYPE> ConfigBuilderSupport.ConfiguredBuilder<BUILDER,PROTOTYPE>
- Direct Known Subclasses:
ThroughputLimitConfig.Builder
- Enclosing interface:
ThroughputLimitConfig
public abstract static class ThroughputLimitConfig.BuilderBase<BUILDER extends ThroughputLimitConfig.BuilderBase<BUILDER,PROTOTYPE>,PROTOTYPE extends ThroughputLimitConfig>
extends Object
implements ConfigBuilderSupport.ConfiguredBuilder<BUILDER,PROTOTYPE>
Fluent API builder base for
ThroughputLimitConfig.-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionprotected static classGenerated implementation of the prototype, can be extended by descendant prototype implementations. -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionintamount()Number of operations to allow during the relevant time window.amount(int amount) Number of operations to allow during the relevant time window.Clear existing value of clock.Clear existing value of semaphore.clock()A clock that supplies nanosecond time.A clock that supplies nanosecond time.config()Configuration used to configure this instance.Deprecated.Update builder from configuration (node of this type).duration()Duration of the time window over which operations will be counted.Duration of the time window over which operations will be counted.booleanWhether to collect metrics for the throughput limit implementation.enableMetrics(boolean enableMetrics) Whether to collect metrics for the throughput limit implementation.booleanfair()Whether theSemaphoreshould beSemaphore.isFair().fair(boolean fair) Whether theSemaphoreshould beSemaphore.isFair().from(ThroughputLimitConfig prototype) Update this builder from an existing prototype instance.from(ThroughputLimitConfig.BuilderBase<?, ?> builder) Update this builder from an existing prototype builder instance.name()Name of this instance.Name of this instance.protected voidHandles providers and decorators.intHow many requests can be enqueued waiting for a permit.queueLength(int queueLength) How many requests can be enqueued waiting for a permit.How long to wait for a permit when enqueued.queueTimeout(Duration queueTimeout) How long to wait for a permit when enqueued.The rate limiting algorithm to apply.rateLimitingAlgorithm(RateLimitingAlgorithmType rateLimitingAlgorithm) The rate limiting algorithm to apply.Explicitly configured semaphore.Explicitly configured semaphore.toString()protected voidValidates required properties.Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, waitMethods inherited from interface io.helidon.builder.api.Prototype.Builder
buildPrototype, self
-
Constructor Details
-
BuilderBase
protected BuilderBase()Protected to support extensibility.
-
-
Method Details
-
from
Update this builder from an existing prototype instance. This method disables automatic service discovery.- Parameters:
prototype- existing prototype to update this builder from- Returns:
- updated builder instance
-
from
Update this builder from an existing prototype builder instance.- Parameters:
builder- existing builder prototype to update this builder from- Returns:
- updated builder instance
-
config
Deprecated.Update builder from configuration (node of this type). If a value is present in configuration, it would override currently configured values.- Specified by:
configin interfaceConfigBuilderSupport.ConfiguredBuilder<BUILDER extends ThroughputLimitConfig.BuilderBase<BUILDER,PROTOTYPE>, PROTOTYPE extends ThroughputLimitConfig> - Parameters:
config- configuration instance used to obtain values to update this builder- Returns:
- updated builder instance
-
config
Update builder from configuration (node of this type). If a value is present in configuration, it would override currently configured values.- Specified by:
configin interfaceConfigBuilderSupport.ConfiguredBuilder<BUILDER extends ThroughputLimitConfig.BuilderBase<BUILDER,PROTOTYPE>, PROTOTYPE extends ThroughputLimitConfig> - Parameters:
config- configuration instance used to obtain values to update this builder- Returns:
- updated builder instance
-
rateLimitingAlgorithm
The rate limiting algorithm to apply. Rate limiting algorithm is by defaultRateLimitingAlgorithmType.TOKEN_BUCKET.- Parameters:
rateLimitingAlgorithm- the rate limiting algorithm to be applied- Returns:
- updated builder instance
- See Also:
-
amount
Number of operations to allow during the relevant time window. Defaults to 0. When set to0, we switch to unlimited.- Parameters:
amount- number of permits- Returns:
- updated builder instance
- See Also:
-
duration
Duration of the time window over which operations will be counted. Defaults to "PT1S"- Parameters:
duration- duration of the time window- Returns:
- updated builder instance
- See Also:
-
fair
- Parameters:
fair- whether this should be a fair semaphore- Returns:
- updated builder instance
- See Also:
-
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 theThroughputLimitimplementation. Default value is 0. If set to {code 0}, there is no queueing.- Parameters:
queueLength- number of requests to enqueue- Returns:
- updated builder instance
- See Also:
-
queueTimeout
How long to wait for a permit when enqueued. Defaults to "PT1S"- Parameters:
queueTimeout- duration of the timeout- Returns:
- updated builder instance
- See Also:
-
name
Name of this instance.- Parameters:
name- name of the instance- Returns:
- updated builder instance
- See Also:
-
clearSemaphore
Clear existing value of semaphore.- Returns:
- updated builder instance
- See Also:
-
semaphore
Explicitly configured semaphore. Note that if this is set, all other configuration is ignored.- Parameters:
semaphore- semaphore instance- Returns:
- updated builder instance
- See Also:
-
clearClock
Clear existing value of clock.- Returns:
- updated builder instance
- See Also:
-
clock
A clock that supplies nanosecond time.- Parameters:
clock- supplier of current nanoseconds, defaults toSystem.nanoTime()- Returns:
- updated builder instance
- See Also:
-
enableMetrics
Whether to collect metrics for the throughput limit implementation.- Parameters:
enableMetrics- metrics flag- Returns:
- updated builder instance
- See Also:
-
rateLimitingAlgorithm
The rate limiting algorithm to apply. Rate limiting algorithm is by defaultRateLimitingAlgorithmType.TOKEN_BUCKET.- Returns:
- the rate limiting algorithm to be applied
-
amount
public int amount()Number of operations to allow during the relevant time window. Defaults to 0. When set to0, we switch to unlimited.- Returns:
- number of permits
-
duration
Duration of the time window over which operations will be counted. Defaults to "PT1S"- Returns:
- duration of the time window
-
fair
public boolean fair()- Returns:
- whether this should be a fair semaphore
-
queueLength
public 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 theThroughputLimitimplementation. Default value is 0. If set to {code 0}, there is no queueing.- Returns:
- number of requests to enqueue
-
queueTimeout
How long to wait for a permit when enqueued. Defaults to "PT1S"- Returns:
- duration of the timeout
-
name
Name of this instance.- Returns:
- name of the instance
-
semaphore
Explicitly configured semaphore. Note that if this is set, all other configuration is ignored.- Returns:
- semaphore instance
-
clock
A clock that supplies nanosecond time.- Returns:
- supplier of current nanoseconds, defaults to
System.nanoTime()
-
enableMetrics
public boolean enableMetrics()Whether to collect metrics for the throughput limit implementation.- Returns:
- metrics flag
-
toString
-
preBuildPrototype
protected void preBuildPrototype()Handles providers and decorators. -
validatePrototype
protected void validatePrototype()Validates required properties. -
config
Configuration used to configure this instance.- Returns:
- config instance
-
config(io.helidon.config.Config)