use of org.apache.servicecomb.governance.handler.RetryHandler in project java-chassis by ServiceComb.
the class InvokerUtils method decorateReactiveRetry.
private static void decorateReactiveRetry(Invocation invocation, DecorateCompletionStage<Response> dcs, GovernanceRequest request) {
// governance implementations.
RetryHandler retryHandler = BeanUtils.getBean(RetryHandler.class);
Retry retry = retryHandler.getActuator(request);
if (retry != null) {
dcs.withRetry(retry, getOrCreateRetryPool());
}
if (isCompatibleRetryEnabled(invocation)) {
// compatible implementation for retry in load balance module in old versions.
retry = getOrCreateCompatibleRetry(invocation);
dcs.withRetry(retry, getOrCreateRetryPool());
}
}
use of org.apache.servicecomb.governance.handler.RetryHandler in project java-chassis by ServiceComb.
the class InvokerUtils method decorateSyncRetry.
private static Response decorateSyncRetry(Invocation invocation, GovernanceRequest request) {
try {
// governance implementations.
RetryHandler retryHandler = BeanUtils.getBean(RetryHandler.class);
Retry retry = retryHandler.getActuator(request);
if (retry != null) {
CheckedFunction0<Response> supplier = Retry.decorateCheckedSupplier(retry, () -> innerSyncInvokeImpl(invocation));
return Try.of(supplier).get();
}
if (isCompatibleRetryEnabled(invocation)) {
// compatible implementation for retry in load balance module in old versions.
retry = getOrCreateCompatibleRetry(invocation);
CheckedFunction0<Response> supplier = Retry.decorateCheckedSupplier(retry, () -> innerSyncInvokeImpl(invocation));
return Try.of(supplier).get();
}
// retry not enabled
return innerSyncInvokeImpl(invocation);
} catch (Throwable e) {
String message = String.format("invoke failed, operation %s, trace id %s", invocation.getMicroserviceQualifiedName(), invocation.getTraceId());
LOGGER.error(message, e);
Response response = Response.createConsumerFail(e, message);
invocation.onFinish(response);
return response;
}
}
Aggregations