ru.tinkoff.kora.resilient.circuitbreaker.CircuitBreakerModule Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of resilient-kora Show documentation
Show all versions of resilient-kora Show documentation
Kora resilient-kora module
The newest version!
package ru.tinkoff.kora.resilient.circuitbreaker;
import jakarta.annotation.Nullable;
import ru.tinkoff.kora.application.graph.All;
import ru.tinkoff.kora.config.common.Config;
import ru.tinkoff.kora.config.common.extractor.ConfigValueExtractor;
public interface CircuitBreakerModule {
default CircuitBreakerConfig koraCircuitBreakerConfig(Config config, ConfigValueExtractor extractor) {
var resilient = config.get("resilient");
return extractor.extract(resilient);
}
default CircuitBreakerManager koraCircuitBreakerManager(CircuitBreakerConfig config,
All failurePredicates,
@Nullable CircuitBreakerMetrics metrics) {
return new KoraCircuitBreakerManager(config, failurePredicates,
(metrics == null)
? new NoopCircuitBreakerMetrics()
: metrics);
}
default CircuitBreakerPredicate koraDefaultCircuitBreakerFailurePredicate() {
return new KoraCircuitBreakerPredicate();
}
}