forked from ReactiveX/RxJava
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Issue 773': Added Circuit breaker Config Customizer Support (Reactive…
- Loading branch information
Showing
16 changed files
with
240 additions
and
62 deletions.
There are no files selected for viewing
21 changes: 21 additions & 0 deletions
21
...thub/resilience4j/common/circuitbreaker/configuration/CircuitBreakerConfigCustomizer.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
package io.github.resilience4j.common.circuitbreaker.configuration; | ||
|
||
import io.github.resilience4j.circuitbreaker.CircuitBreakerConfig; | ||
|
||
/** | ||
* Enable customization circuit breaker configuration builders programmatically. | ||
*/ | ||
public interface CircuitBreakerConfigCustomizer { | ||
|
||
/** | ||
* Customize circuit breaker configuration builder. | ||
* | ||
* @param configBuilder to be customized | ||
*/ | ||
void customize(CircuitBreakerConfig.Builder configBuilder); | ||
|
||
/** | ||
* @return name of the circuit breaker instance to be customized | ||
*/ | ||
String name(); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
36 changes: 36 additions & 0 deletions
36
...b/resilience4j/common/circuitbreaker/configuration/CompositeCircuitBreakerCustomizer.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
package io.github.resilience4j.common.circuitbreaker.configuration; | ||
|
||
import java.util.HashMap; | ||
import java.util.List; | ||
import java.util.Map; | ||
import java.util.Optional; | ||
import java.util.function.Function; | ||
import java.util.stream.Collectors; | ||
|
||
/** | ||
* the composite of any circuit breaker {@link CircuitBreakerConfigCustomizer} implementations. | ||
*/ | ||
public class CompositeCircuitBreakerCustomizer { | ||
|
||
final Map<String, CircuitBreakerConfigCustomizer> customizerMap = new HashMap<>(); | ||
|
||
public CompositeCircuitBreakerCustomizer(List<CircuitBreakerConfigCustomizer> customizers) { | ||
|
||
if (customizers != null && !customizers.isEmpty()) { | ||
customizerMap.putAll(customizers.stream() | ||
.collect( | ||
Collectors.toMap(CircuitBreakerConfigCustomizer::name, Function.identity()))); | ||
} | ||
|
||
} | ||
|
||
/** | ||
* @param circuitBreakerInstanceName the circuit breaker instance name | ||
* @return the found {@link CircuitBreakerConfigCustomizer} if any . | ||
*/ | ||
public Optional<CircuitBreakerConfigCustomizer> getCircuitBreakerConfigCustomizer( | ||
String circuitBreakerInstanceName) { | ||
return Optional.ofNullable(customizerMap.get(circuitBreakerInstanceName)); | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.