Package com.shri.restinpeace
Class BulkheadConfig
java.lang.Object
com.shri.restinpeace.BulkheadConfig
Per-client concurrency cap for
RIP.getClient(Class, RipClientConfig) -
bounds how many calls to this client can be in flight at once, so one slow
or hung downstream can't starve every other call sharing the same
connection pool/thread capacity. See docs/design/circuit-breaker-bulkhead.md
for the full design, personas, and the reasoning behind every default
below.
Unlike CircuitBreakerConfig, this isn't about a downstream's
failure rate at all - it's a plain concurrency throttle, tripped by
volume alone, regardless of whether calls are succeeding or failing.
UserApi api = RIP.getClient(UserApi.class, RipClientConfig.builder()
.bulkhead(BulkheadConfig.builder()
.maxConcurrentCalls(25)
.maxWaitDuration(Duration.ofMillis(500))
.build())
.build());
-
Nested Class Summary
Nested Classes -
Method Summary
Modifier and TypeMethodDescriptionstatic BulkheadConfig.Builderbuilder()Starts building a new config, defaulting to 25 max concurrent calls and failing fast (no wait) once that many are already in flight - resilience4j's own default shape for the same feature.intReturns the concurrency cap.longReturns how long a call waits for a free permit before being refused.
-
Method Details
-
builder
Starts building a new config, defaulting to 25 max concurrent calls and failing fast (no wait) once that many are already in flight - resilience4j's own default shape for the same feature.- Returns:
- a new builder
-
getMaxConcurrentCalls
public int getMaxConcurrentCalls()Returns the concurrency cap.- Returns:
- the maximum number of calls to this client permitted in flight at once
-
getMaxWaitDurationMillis
public long getMaxWaitDurationMillis()Returns how long a call waits for a free permit before being refused.- Returns:
- the maximum wait for a permit, in milliseconds;
0means fail immediately instead of waiting at all
-