Class CircuitBreakerBuilder<T extends io.dropwizard.Configuration>
- java.lang.Object
-
- org.sdase.commons.server.circuitbreaker.builder.CircuitBreakerBuilder<T>
-
- All Implemented Interfaces:
CircuitBreakerConfigurationBuilder<T>
,CircuitBreakerExceptionBuilder<T>
,CircuitBreakerFinalBuilder
public class CircuitBreakerBuilder<T extends io.dropwizard.Configuration> extends java.lang.Object implements CircuitBreakerConfigurationBuilder<T>, CircuitBreakerExceptionBuilder<T>, CircuitBreakerFinalBuilder
-
-
Constructor Summary
Constructors Constructor Description CircuitBreakerBuilder(java.lang.String name, io.github.resilience4j.circuitbreaker.CircuitBreakerRegistry registry, T configuration)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description io.github.resilience4j.circuitbreaker.CircuitBreaker
build()
Create a new circuit breaker instance.CircuitBreakerExceptionBuilder<T>
ignoreExceptions(java.lang.Class<? extends java.lang.Throwable>... errorClasses)
Configures a list of error classes that are ignored as a failure and thus do not increase the failure rate.CircuitBreakerExceptionBuilder<T>
recordExceptions(java.lang.Class<? extends java.lang.Throwable>... errorClasses)
Configures a list of error classes that are recorded as a failure and thus increase the failure rate.CircuitBreakerExceptionBuilder<T>
withConfigProvider(CircuitBreakerConfigurationProvider<T> provider)
Set a provider for a custom configuration for the circuit breaker.CircuitBreakerExceptionBuilder<T>
withCustomConfig(CircuitBreakerConfiguration config)
Set a custom configuration for the circuit breaker.CircuitBreakerExceptionBuilder<T>
withDefaultConfig()
Use the default configuration of the bundle for the circuit breaker.<U> U
wrap(U target)
Wrap target with a circuit breaker
-
-
-
Constructor Detail
-
CircuitBreakerBuilder
public CircuitBreakerBuilder(java.lang.String name, io.github.resilience4j.circuitbreaker.CircuitBreakerRegistry registry, T configuration)
-
-
Method Detail
-
withCustomConfig
public CircuitBreakerExceptionBuilder<T> withCustomConfig(CircuitBreakerConfiguration config)
Description copied from interface:CircuitBreakerConfigurationBuilder
Set a custom configuration for the circuit breaker.- Specified by:
withCustomConfig
in interfaceCircuitBreakerConfigurationBuilder<T extends io.dropwizard.Configuration>
- Parameters:
config
- The config to apply.- Returns:
- the same builder instance
-
withConfigProvider
public CircuitBreakerExceptionBuilder<T> withConfigProvider(CircuitBreakerConfigurationProvider<T> provider)
Description copied from interface:CircuitBreakerConfigurationBuilder
Set a provider for a custom configuration for the circuit breaker.- Specified by:
withConfigProvider
in interfaceCircuitBreakerConfigurationBuilder<T extends io.dropwizard.Configuration>
- Parameters:
provider
- The provider to load the config from the Dropwizard config.- Returns:
- the same builder instance
-
withDefaultConfig
public CircuitBreakerExceptionBuilder<T> withDefaultConfig()
Description copied from interface:CircuitBreakerConfigurationBuilder
Use the default configuration of the bundle for the circuit breaker.- Specified by:
withDefaultConfig
in interfaceCircuitBreakerConfigurationBuilder<T extends io.dropwizard.Configuration>
- Returns:
- the same builder instance
-
recordExceptions
public CircuitBreakerExceptionBuilder<T> recordExceptions(java.lang.Class<? extends java.lang.Throwable>... errorClasses)
Description copied from interface:CircuitBreakerExceptionBuilder
Configures a list of error classes that are recorded as a failure and thus increase the failure rate. Any exception matching or inheriting from one of the list should count as a failure, unless ignored- Specified by:
recordExceptions
in interfaceCircuitBreakerExceptionBuilder<T extends io.dropwizard.Configuration>
- Parameters:
errorClasses
- the error classes that are recorded- Returns:
- the same builder instance
-
ignoreExceptions
public CircuitBreakerExceptionBuilder<T> ignoreExceptions(java.lang.Class<? extends java.lang.Throwable>... errorClasses)
Description copied from interface:CircuitBreakerExceptionBuilder
Configures a list of error classes that are ignored as a failure and thus do not increase the failure rate. Any exception matching or inheriting from one of the list will not count as a failure, even if marked via record.- Specified by:
ignoreExceptions
in interfaceCircuitBreakerExceptionBuilder<T extends io.dropwizard.Configuration>
- Parameters:
errorClasses
- the error classes that are ignored- Returns:
- the same builder instance
-
build
public io.github.resilience4j.circuitbreaker.CircuitBreaker build()
Description copied from interface:CircuitBreakerFinalBuilder
Create a new circuit breaker instance.- Specified by:
build
in interfaceCircuitBreakerFinalBuilder
- Returns:
- A new
CircuitBreaker
-
wrap
public <U> U wrap(U target)
Description copied from interface:CircuitBreakerFinalBuilder
Wrap target with a circuit breaker- Specified by:
wrap
in interfaceCircuitBreakerFinalBuilder
- Type Parameters:
U
- The type of the target- Parameters:
target
- The target to wrap. Final classes have to implement an interface.- Returns:
- A proxy object that passes all calls to target, but wraps them in a circuit breaker.
-
-