Search in sources :

Example 1 with IntervalFunction

use of io.github.resilience4j.core.IntervalFunction in project java-chassis by ServiceComb.

the class RetryHandler method getRetry.

private Retry getRetry(RetryPolicy retryPolicy) {
    LOGGER.info("applying new policy: {}", retryPolicy.toString());
    RetryConfig config = RetryConfig.custom().maxAttempts(retryPolicy.getMaxAttempts() + 1).retryOnResult(response -> retryExtension.isRetry(retryPolicy.getRetryOnResponseStatus(), response)).retryOnException(e -> retryExtension.isRetry(e)).intervalFunction(getIntervalFunction(retryPolicy)).build();
    RetryRegistry registry = RetryRegistry.of(config);
    return registry.retry(retryPolicy.getName());
}
Also used : Logger(org.slf4j.Logger) Retry(io.github.resilience4j.retry.Retry) RetryConfig(io.github.resilience4j.retry.RetryConfig) LoggerFactory(org.slf4j.LoggerFactory) Autowired(org.springframework.beans.factory.annotation.Autowired) IntervalFunction(io.github.resilience4j.core.IntervalFunction) RetryExtension(org.apache.servicecomb.governance.handler.ext.RetryExtension) GovernanceUtils(org.apache.servicecomb.governance.utils.GovernanceUtils) Component(org.springframework.stereotype.Component) GovernanceRequest(org.apache.servicecomb.governance.marker.GovernanceRequest) Duration(java.time.Duration) RetryProperties(org.apache.servicecomb.governance.properties.RetryProperties) RetryRegistry(io.github.resilience4j.retry.RetryRegistry) RetryPolicy(org.apache.servicecomb.governance.policy.RetryPolicy) RetryConfig(io.github.resilience4j.retry.RetryConfig) RetryRegistry(io.github.resilience4j.retry.RetryRegistry)

Aggregations

IntervalFunction (io.github.resilience4j.core.IntervalFunction)1 Retry (io.github.resilience4j.retry.Retry)1 RetryConfig (io.github.resilience4j.retry.RetryConfig)1 RetryRegistry (io.github.resilience4j.retry.RetryRegistry)1 Duration (java.time.Duration)1 RetryExtension (org.apache.servicecomb.governance.handler.ext.RetryExtension)1 GovernanceRequest (org.apache.servicecomb.governance.marker.GovernanceRequest)1 RetryPolicy (org.apache.servicecomb.governance.policy.RetryPolicy)1 RetryProperties (org.apache.servicecomb.governance.properties.RetryProperties)1 GovernanceUtils (org.apache.servicecomb.governance.utils.GovernanceUtils)1 Logger (org.slf4j.Logger)1 LoggerFactory (org.slf4j.LoggerFactory)1 Autowired (org.springframework.beans.factory.annotation.Autowired)1 Component (org.springframework.stereotype.Component)1