Class FixedCapacityLimiterBuilder
java.lang.Object
io.servicetalk.capacity.limiter.api.FixedCapacityLimiterBuilder
A builder for fixed capacity
CapacityLimiter
.-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic interface
A state observer for the fixedCapacityLimiter
to monitor internal limit and consumption. -
Method Summary
Modifier and TypeMethodDescriptionbuild()
Build a fixed capacityCapacityLimiter
according to this configuration.capacity
(int capacity) Defines the fixed capacity for theCapacityLimiter
.Defines a name for thisCapacityLimiter
.Aobserver
to consume the current consumed capacity.
-
Method Details
-
name
Defines a name for thisCapacityLimiter
.- Parameters:
name
- the name to be used when building thisCapacityLimiter
.- Returns:
this
.
-
capacity
Defines the fixed capacity for theCapacityLimiter
. Concurrent requests above this figure will be rejected. Requests with particularpriority
will be respected and the total capacity for them will be adjusted accordingly.- Parameters:
capacity
- The max allowed concurrent requests that thisCapacityLimiter
should allow.- Returns:
this
.
-
stateObserver
public FixedCapacityLimiterBuilder stateObserver(FixedCapacityLimiterBuilder.StateObserver observer) Aobserver
to consume the current consumed capacity. Useful for logging, metrics, or just debugging.The rate of reporting limit and consumption to the observer is based on the rate of change to this
CapacityLimiter
.It's expected that this
FixedCapacityLimiterBuilder.StateObserver
is not going to block the thread that invokes it.- Parameters:
observer
- TheFixedCapacityLimiterBuilder.StateObserver
to inform about the current consumption of thisCapacityLimiter
.- Returns:
this
.
-
build
Build a fixed capacityCapacityLimiter
according to this configuration.- Returns:
- A new instance of
CapacityLimiter
according to this configuration.
-