Class CircuitBreakerBundle<T extends io.dropwizard.Configuration>
- java.lang.Object
-
- org.sdase.commons.server.circuitbreaker.CircuitBreakerBundle<T>
-
- All Implemented Interfaces:
io.dropwizard.ConfiguredBundle<T>
public class CircuitBreakerBundle<T extends io.dropwizard.Configuration> extends java.lang.Object implements io.dropwizard.ConfiguredBundle<T>
Bundle that provides access to an implementation of the circuit breaker pattern to handle failures of downstream services. The bundle uses resilience4j and exposes instances ofCircuitBreaker
.The bundle allows to create circuit breakers, wrap classes in circuit breakers and registers prometheus metrics.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static class
CircuitBreakerBundle.Builder<C extends io.dropwizard.Configuration>
static interface
CircuitBreakerBundle.ConfigurationBuilder
static interface
CircuitBreakerBundle.ExceptionBuilder<T extends io.dropwizard.Configuration>
static interface
CircuitBreakerBundle.FinalBuilder<T extends io.dropwizard.Configuration>
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description static CircuitBreakerBundle.ConfigurationBuilder
builder()
Builder for creating a new instance.CircuitBreakerConfigurationBuilder<io.dropwizard.Configuration>
createCircuitBreaker(java.lang.String name)
Create a new circuit breaker builder.io.github.resilience4j.circuitbreaker.CircuitBreakerRegistry
getRegistry()
Returns the circuit breaker registry created by the bundle.void
initialize(io.dropwizard.setup.Bootstrap<?> bootstrap)
void
run(T configuration, io.dropwizard.setup.Environment environment)
-
-
-
Method Detail
-
initialize
public void initialize(io.dropwizard.setup.Bootstrap<?> bootstrap)
- Specified by:
initialize
in interfaceio.dropwizard.ConfiguredBundle<T extends io.dropwizard.Configuration>
-
run
public void run(T configuration, io.dropwizard.setup.Environment environment)
- Specified by:
run
in interfaceio.dropwizard.ConfiguredBundle<T extends io.dropwizard.Configuration>
-
createCircuitBreaker
public CircuitBreakerConfigurationBuilder<io.dropwizard.Configuration> createCircuitBreaker(java.lang.String name)
Create a new circuit breaker builder.- Parameters:
name
- The name of the circuit breaker, used in the metrics. Multiple calls with the same name return the same circuit breaker- Returns:
- A circuit breaker builder.
-
getRegistry
public io.github.resilience4j.circuitbreaker.CircuitBreakerRegistry getRegistry()
Returns the circuit breaker registry created by the bundle.- Returns:
- The circuit breaker registry.
-
builder
public static CircuitBreakerBundle.ConfigurationBuilder builder()
Builder for creating a new instance.- Returns:
- Builder
-
-