Class RetryingClient
java.lang.Object
com.linecorp.armeria.common.util.AbstractUnwrappable<Client<T_I,T_O>>
com.linecorp.armeria.client.DecoratingClient<I,O,I,O>
com.linecorp.armeria.client.SimpleDecoratingClient<I,O>
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 RetryingClientBuilder
builder(RetryConfig<HttpResponse> retryConfig)
Returns a newRetryingClientBuilder
with the specifiedRetryConfig
.static RetryingClientBuilder
Returns a newRetryingClientBuilder
with the specifiedRetryRule
.static RetryingClientBuilder
builder(RetryRuleWithContent<HttpResponse> retryRuleWithContent)
Returns a newRetryingClientBuilder
with the specifiedRetryRuleWithContent
.static RetryingClientBuilder
builder(RetryRuleWithContent<HttpResponse> retryRuleWithContent, int maxContentLength)
Returns a newRetryingClientBuilder
with the specifiedRetryRuleWithContent
and the specifiedmaxContentLength
.static RetryingClientBuilder
builderWithMapping(RetryConfigMapping<HttpResponse> mapping)
Returns a newRetryingClientBuilder
with the specifiedRetryConfigMapping
.protected HttpResponse
doExecute(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 newHttpClient
decorator that handles failures of an invocation and retries HTTP requests.static Function<? super HttpClient,RetryingClient>
newDecorator(RetryRule retryRule)
Creates a newHttpClient
decorator 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 newHttpClient
decorator with the specifiedRetryRuleWithContent
that 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 newHttpClient
decorator 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, setResponseTimeout
Methods inherited from class com.linecorp.armeria.common.util.AbstractUnwrappable
as, toString, unwrap
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
Methods inherited from interface com.linecorp.armeria.client.HttpClient
execute
-
Method Details
-
builder
Returns a newRetryingClientBuilder
with the specifiedRetryConfig
. TheRetryConfig
object encapsulatesRetryRule
orRetryRuleWithContent
,maxContentLength
,maxTotalAttempts
andresponseTimeoutMillisForEachAttempt
. -
builder
Returns a newRetryingClientBuilder
with the specifiedRetryRule
. -
builder
public static RetryingClientBuilder builder(RetryRuleWithContent<HttpResponse> retryRuleWithContent)Returns a newRetryingClientBuilder
with the specifiedRetryRuleWithContent
. -
builder
public static RetryingClientBuilder builder(RetryRuleWithContent<HttpResponse> retryRuleWithContent, int maxContentLength)Returns a newRetryingClientBuilder
with the specifiedRetryRuleWithContent
and the specifiedmaxContentLength
. ThemaxContentLength
required 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 specifiedmaxContentLength
is equal to or less than0
-
builderWithMapping
Returns a newRetryingClientBuilder
with the specifiedRetryConfigMapping
. -
newDecorator
Creates a newHttpClient
decorator 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 newHttpClient
decorator with the specifiedRetryRuleWithContent
that 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 newHttpClient
decorator 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 newHttpClient
decorator with the specifiedRetryRuleWithContent
that 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 newHttpClient
decorator 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.0
disables the timeout
-
newDecorator
@Deprecated public static Function<? super HttpClient,RetryingClient> newDecorator(RetryRuleWithContent<HttpResponse> retryRuleWithContent, int maxTotalAttempts, long responseTimeoutMillisForEachAttempt)Deprecated.UsenewDecorator(RetryConfig)
instead.Creates a newHttpClient
decorator with the specifiedRetryRuleWithContent
that 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.0
disables the timeout
-
newDecorator
public static Function<? super HttpClient,RetryingClient> newDecorator(RetryConfig<HttpResponse> retryConfig)Creates a newHttpClient
decorator that handles failures of an invocation and retries HTTP requests. TheRetryConfig
object encapsulatesRetryRule
orRetryRuleWithContent
,maxContentLength
,maxTotalAttempts
andresponseTimeoutMillisForEachAttempt
. -
newDecoratorWithMapping
public static Function<? super HttpClient,RetryingClient> newDecoratorWithMapping(RetryConfigMapping<HttpResponse> mapping)Creates a newHttpClient
decorator that handles failures of an invocation and retries HTTP requests.- Parameters:
mapping
- the mapping that returns aRetryConfig
for a givenClientRequestContext
andRequest
.
-
doExecute
Description copied from class:AbstractRetryingClient
Invoked byAbstractRetryingClient.execute(ClientRequestContext, Request)
after the deadline for response timeout is set.- Specified by:
doExecute
in classAbstractRetryingClient<HttpRequest,HttpResponse>
- Throws:
Exception
-
newDecorator(RetryConfig)
instead.