Class RetryingClient
java.lang.Object
com.linecorp.armeria.common.util.AbstractUnwrappable<Client<HttpRequest,HttpResponse>>
com.linecorp.armeria.client.DecoratingClient<HttpRequest,HttpResponse,HttpRequest,HttpResponse>
com.linecorp.armeria.client.SimpleDecoratingClient<HttpRequest,HttpResponse>
com.linecorp.armeria.client.retry.AbstractRetryingClient<HttpRequest,HttpResponse>
com.linecorp.armeria.client.retry.RetryingClient
- All Implemented Interfaces:
Client<HttpRequest,,HttpResponse> HttpClient,Unwrappable
public final class RetryingClient
extends AbstractRetryingClient<HttpRequest,HttpResponse>
implements HttpClient
An
HttpClient decorator that handles failures of an invocation and retries HTTP requests.-
Field Summary
Fields inherited from class com.linecorp.armeria.client.retry.AbstractRetryingClient
ARMERIA_RETRY_COUNT -
Method Summary
Modifier and TypeMethodDescriptionstatic RetryingClientBuilderbuilder(RetryConfig<HttpResponse> retryConfig) Returns a newRetryingClientBuilderwith the specifiedRetryConfig.static RetryingClientBuilderReturns a newRetryingClientBuilderwith the specifiedRetryRule.static RetryingClientBuilderbuilder(RetryRuleWithContent<HttpResponse> retryRuleWithContent) Returns a newRetryingClientBuilderwith the specifiedRetryRuleWithContent.static RetryingClientBuilderbuilder(RetryRuleWithContent<HttpResponse> retryRuleWithContent, int maxContentLength) Returns a newRetryingClientBuilderwith the specifiedRetryRuleWithContentand the specifiedmaxContentLength.static RetryingClientBuilderbuilderWithMapping(RetryConfigMapping<HttpResponse> mapping) Returns a newRetryingClientBuilderwith the specifiedRetryConfigMapping.protected HttpResponsedoExecute(ClientRequestContext ctx, HttpRequest req) Invoked byAbstractRetryingClient.execute(ClientRequestContext, Request)after the deadline for response timeout is set.static Function<? super HttpClient, RetryingClient> newDecorator(RetryConfig<HttpResponse> retryConfig) Creates a newHttpClientdecorator that handles failures of an invocation and retries HTTP requests.static Function<? super HttpClient, RetryingClient> newDecorator(RetryRule retryRule) Creates a newHttpClientdecorator that handles failures of an invocation and retries HTTP requests.static Function<? super HttpClient, RetryingClient> newDecorator(RetryRule retryRule, int maxTotalAttempts) Deprecated.static Function<? super HttpClient, RetryingClient> newDecorator(RetryRule retryRule, int maxTotalAttempts, long responseTimeoutMillisForEachAttempt) Deprecated.UsenewDecorator(RetryConfig)instead.static Function<? super HttpClient, RetryingClient> newDecorator(RetryRuleWithContent<HttpResponse> retryRuleWithContent) Creates a newHttpClientdecorator with the specifiedRetryRuleWithContentthat handles failures of an invocation and retries HTTP requests.static Function<? super HttpClient, RetryingClient> newDecorator(RetryRuleWithContent<HttpResponse> retryRuleWithContent, int maxTotalAttempts) Deprecated.UsenewDecorator(RetryConfig)instead.static Function<? super HttpClient, RetryingClient> newDecorator(RetryRuleWithContent<HttpResponse> retryRuleWithContent, int maxTotalAttempts, long responseTimeoutMillisForEachAttempt) Deprecated.UsenewDecorator(RetryConfig)instead.static Function<? super HttpClient, RetryingClient> Creates a newHttpClientdecorator that handles failures of an invocation and retries HTTP requests.Methods inherited from class com.linecorp.armeria.client.retry.AbstractRetryingClient
execute, getNextDelay, getNextDelay, getTotalAttempts, mapping, newDerivedContext, onRetryingComplete, retryRule, retryRuleWithContent, scheduleNextRetry, setResponseTimeoutMethods inherited from class com.linecorp.armeria.common.util.AbstractUnwrappable
as, toString, unwrap, unwrapAllMethods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, waitMethods inherited from interface com.linecorp.armeria.client.HttpClient
executeMethods inherited from interface com.linecorp.armeria.common.util.Unwrappable
equalsIgnoreWrapper, unwrapAll
-
Method Details
-
builder
Returns a newRetryingClientBuilderwith the specifiedRetryConfig. TheRetryConfigobject encapsulatesRetryRuleorRetryRuleWithContent,maxContentLength,maxTotalAttemptsandresponseTimeoutMillisForEachAttempt. -
builder
Returns a newRetryingClientBuilderwith the specifiedRetryRule. -
builder
public static RetryingClientBuilder builder(RetryRuleWithContent<HttpResponse> retryRuleWithContent) Returns a newRetryingClientBuilderwith the specifiedRetryRuleWithContent. -
builder
public static RetryingClientBuilder builder(RetryRuleWithContent<HttpResponse> retryRuleWithContent, int maxContentLength) Returns a newRetryingClientBuilderwith the specifiedRetryRuleWithContentand the specifiedmaxContentLength. ThemaxContentLengthrequired to determine whether to retry or not. If the total length of content exceeds this length and there's no retry condition matched, it will hand over the stream to the client.- Throws:
IllegalArgumentException- if the specifiedmaxContentLengthis equal to or less than0
-
builderWithMapping
Returns a newRetryingClientBuilderwith the specifiedRetryConfigMapping. -
newDecorator
Creates a newHttpClientdecorator that handles failures of an invocation and retries HTTP requests.- Parameters:
retryRule- the retry rule
-
newDecorator
public static Function<? super HttpClient,RetryingClient> newDecorator(RetryRuleWithContent<HttpResponse> retryRuleWithContent) Creates a newHttpClientdecorator with the specifiedRetryRuleWithContentthat handles failures of an invocation and retries HTTP requests.- Parameters:
retryRuleWithContent- the retry rule
-
newDecorator
@Deprecated public static Function<? super HttpClient,RetryingClient> newDecorator(RetryRule retryRule, int maxTotalAttempts) Deprecated.UsenewDecorator(RetryConfig)instead.Creates a newHttpClientdecorator that handles failures of an invocation and retries HTTP requests.- Parameters:
retryRule- the retry rulemaxTotalAttempts- the maximum allowed number of total attempts
-
newDecorator
@Deprecated public static Function<? super HttpClient,RetryingClient> newDecorator(RetryRuleWithContent<HttpResponse> retryRuleWithContent, int maxTotalAttempts) Deprecated.UsenewDecorator(RetryConfig)instead.Creates a newHttpClientdecorator with the specifiedRetryRuleWithContentthat handles failures of an invocation and retries HTTP requests.- Parameters:
retryRuleWithContent- the retry rulemaxTotalAttempts- the maximum allowed number of total attempts
-
newDecorator
@Deprecated public static Function<? super HttpClient,RetryingClient> newDecorator(RetryRule retryRule, int maxTotalAttempts, long responseTimeoutMillisForEachAttempt) Deprecated.UsenewDecorator(RetryConfig)instead.Creates a newHttpClientdecorator that handles failures of an invocation and retries HTTP requests.- Parameters:
retryRule- the retry rulemaxTotalAttempts- the maximum number of total attemptsresponseTimeoutMillisForEachAttempt- response timeout for each attempt.0disables the timeout
-
newDecorator
@Deprecated public static Function<? super HttpClient,RetryingClient> newDecorator(RetryRuleWithContent<HttpResponse> retryRuleWithContent, int maxTotalAttempts, long responseTimeoutMillisForEachAttempt) Deprecated.UsenewDecorator(RetryConfig)instead.Creates a newHttpClientdecorator with the specifiedRetryRuleWithContentthat handles failures of an invocation and retries HTTP requests.- Parameters:
retryRuleWithContent- the retry rulemaxTotalAttempts- the maximum number of total attemptsresponseTimeoutMillisForEachAttempt- response timeout for each attempt.0disables the timeout
-
newDecorator
public static Function<? super HttpClient,RetryingClient> newDecorator(RetryConfig<HttpResponse> retryConfig) Creates a newHttpClientdecorator that handles failures of an invocation and retries HTTP requests. TheRetryConfigobject encapsulatesRetryRuleorRetryRuleWithContent,maxContentLength,maxTotalAttemptsandresponseTimeoutMillisForEachAttempt. -
newDecoratorWithMapping
public static Function<? super HttpClient,RetryingClient> newDecoratorWithMapping(RetryConfigMapping<HttpResponse> mapping) Creates a newHttpClientdecorator that handles failures of an invocation and retries HTTP requests.- Parameters:
mapping- the mapping that returns aRetryConfigfor a givenClientRequestContextandRequest.
-
doExecute
Description copied from class:AbstractRetryingClientInvoked byAbstractRetryingClient.execute(ClientRequestContext, Request)after the deadline for response timeout is set.- Specified by:
doExecutein classAbstractRetryingClient<HttpRequest,HttpResponse> - Throws:
Exception
-
newDecorator(RetryConfig)instead.