Class DmxBulkhead
java.lang.Object
dmx.fun.resilience4j.DmxBulkhead
dmx-fun adapter for Resilience4J
Bulkhead.
Executes a supplier through the bulkhead and returns a dmx-fun type instead of throwing. Configure the bulkhead using the native Resilience4J API:
DmxBulkhead bh = DmxBulkhead.of("db-pool", BulkheadConfig.ofDefaults());
Try<User> r1 = bh.executeTry(() -> userRepo.findById(id));
Result<User, Throwable> r2 = bh.executeResult(() -> userRepo.findById(id));
Result<User, BulkheadFullException> r3 = bh.executeResultTyped(() -> userRepo.findById(id));
-
Method Summary
Modifier and TypeMethodDescriptionexecuteResult(CheckedSupplier<V> supplier) Executes the supplier through the bulkhead.<V> Result<V, io.github.resilience4j.bulkhead.BulkheadFullException> executeResultTyped(CheckedSupplier<V> supplier) Executes the supplier through the bulkhead, surfacing bulkhead-full rejections as a typed error.<V> Try<V> executeTry(CheckedSupplier<V> supplier) Executes the supplier through the bulkhead.static DmxBulkheadof(io.github.resilience4j.bulkhead.Bulkhead bulkhead) Wraps an existingBulkheadinstance.static DmxBulkheadCreates a newBulkheadfrom the given name and config, then wraps it.
-
Method Details
-
of
Wraps an existingBulkheadinstance.- Parameters:
bulkhead- the Resilience4J bulkhead to wrap- Returns:
- a new
DmxBulkheadbacked by the given bulkhead
-
of
Creates a newBulkheadfrom the given name and config, then wraps it.- Parameters:
name- the bulkhead nameconfig- the bulkhead configuration- Returns:
- a new
DmxBulkheadbacked by the created bulkhead
-
executeTry
Executes the supplier through the bulkhead.- Type Parameters:
V- the value type- Parameters:
supplier- the operation to execute- Returns:
Success(value)on success,Failure(BulkheadFullException)when the bulkhead is saturated, orFailure(cause)when the call itself fails
-
executeResult
Executes the supplier through the bulkhead.- Type Parameters:
V- the value type- Parameters:
supplier- the operation to execute- Returns:
Ok(value)on success,Err(cause)on any failure
-
executeResultTyped
public <V> Result<V, io.github.resilience4j.bulkhead.BulkheadFullException> executeResultTyped(CheckedSupplier<V> supplier) Executes the supplier through the bulkhead, surfacing bulkhead-full rejections as a typed error.- Type Parameters:
V- the value type- Parameters:
supplier- the operation to execute- Returns:
Ok(value)on success,Err(BulkheadFullException)when the bulkhead is saturated; other exceptions from the call propagate as unchecked
-