All Downloads are FREE. Search and download functionalities are using the official Maven repository.

ru.tinkoff.kora.resilient.retry.RetryModule Maven / Gradle / Ivy

The newest version!
package ru.tinkoff.kora.resilient.retry;

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 RetryModule {

    default RetryConfig koraRetryableConfig(Config config, ConfigValueExtractor extractor) {
        var value = config.get("resilient");
        return extractor.extract(value);
    }

    default RetryManager koraRetryableManager(All failurePredicates,
                                              RetryConfig config,
                                              @Nullable RetryMetrics metrics) {
        return new KoraRetryManager(config, failurePredicates,
            metrics == null
                ? new NoopRetryMetrics()
                : metrics);
    }

    default RetryPredicate koraRetryFailurePredicate() {
        return new KoraRetryPredicate();
    }

    default KoraRetryReactorBuilder koraRetryReactorBuilder(All failurePredicates,
                                                            RetryConfig config,
                                                            @Nullable RetryMetrics metrics) {
        return new KoraRetryReactorBuilder(config, failurePredicates,
            metrics == null
                ? new NoopRetryMetrics()
                : metrics);
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy