Skip to content

Commit

Permalink
Additional factory methods
Browse files Browse the repository at this point in the history
These factory methods are identical to the ones already existing in
metrics/CircuitBreakerMetrics.java. Their purpose is to allow
Spring Boot applications to instantiate CircuitBreakerMetrics and
have fine-grained control over which circuit breakers are bound to
metrics, in particular in scenarios where the CircuitBreakerRegistry
may not be completely populated by the time the CircuitBreakerMetrics
class is instantiated.
  • Loading branch information
berrueta committed Aug 18, 2018
1 parent 0004bd2 commit 939e876
Showing 1 changed file with 20 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,26 @@ public static CircuitBreakerMetrics ofCircuitBreakerRegistry(CircuitBreakerRegis
return new CircuitBreakerMetrics(circuitBreakerRegistry.getAllCircuitBreakers());
}

/**
* Creates a new instance CircuitBreakerMetrics {@link CircuitBreakerMetrics} with
* an {@link Iterable} of circuit breakers as a source.
*
* @param circuitBreakers the circuit breakers
*/
public static CircuitBreakerMetrics ofIterable(Iterable<CircuitBreaker> circuitBreakers) {
return new CircuitBreakerMetrics(circuitBreakers);
}

/**
* Creates a new instance CircuitBreakerMetrics {@link CircuitBreakerMetrics} with
* an {@link Iterable} of circuit breakers as a source.
*
* @param circuitBreakers the circuit breakers
*/
public static CircuitBreakerMetrics ofIterable(String prefix, Iterable<CircuitBreaker> circuitBreakers) {
return new CircuitBreakerMetrics(circuitBreakers, prefix);
}

@Override
public void bindTo(MeterRegistry registry) {
for (CircuitBreaker circuitBreaker : circuitBreakers) {
Expand Down

0 comments on commit 939e876

Please sign in to comment.