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 Type Method Description static RetryingClientBuilder
builder(RetryRule retryRule)
Returns a newRetryingClientBuilder
with the specifiedRetryRule
.static RetryingClientBuilder
builder(RetryRuleWithContent<HttpResponse> retryRuleWithContent)
Returns a newRetryingClientBuilder
with the specifiedRetryRuleWithContent
.static RetryingClientBuilder
builder(RetryStrategy retryStrategy)
Deprecated.static RetryingClientBuilder
builder(RetryStrategyWithContent<HttpResponse> retryStrategyWithContent)
Deprecated.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(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)
Creates a newHttpClient
decorator that handles failures of an invocation and retries HTTP requests.static Function<? super HttpClient,RetryingClient>
newDecorator(RetryRule retryRule, int maxTotalAttempts, long responseTimeoutMillisForEachAttempt)
Creates a newHttpClient
decorator that handles failures of an invocation and retries HTTP requests.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)
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, long responseTimeoutMillisForEachAttempt)
Creates a newHttpClient
decorator with the specifiedRetryRuleWithContent
that handles failures of an invocation and retries HTTP requests.static Function<? super HttpClient,RetryingClient>
newDecorator(RetryStrategy retryStrategy)
Deprecated.static Function<? super HttpClient,RetryingClient>
newDecorator(RetryStrategy retryStrategy, int maxTotalAttempts)
Deprecated.static Function<? super HttpClient,RetryingClient>
newDecorator(RetryStrategy retryStrategy, int maxTotalAttempts, long responseTimeoutMillisForEachAttempt)
Deprecated.Methods inherited from class com.linecorp.armeria.client.retry.AbstractRetryingClient
execute, getNextDelay, getNextDelay, getTotalAttempts, newDerivedContext, onRetryingComplete, retryRule, retryRuleWithContent, retryStrategy, retryStrategyWithContent, scheduleNextRetry, setResponseTimeout
Methods inherited from class com.linecorp.armeria.common.util.AbstractUnwrappable
as, delegate, toString
-
Method Details
-
builder
Returns a newRetryingClientBuilder
with the specifiedRetryRule
. -
builder
Deprecated.Returns a newRetryingClientBuilder
with the specifiedRetryStrategy
. -
builder
public static RetryingClientBuilder builder(RetryRuleWithContent<HttpResponse> retryRuleWithContent)Returns a newRetryingClientBuilder
with the specifiedRetryRuleWithContent
. -
builder
@Deprecated public static RetryingClientBuilder builder(RetryStrategyWithContent<HttpResponse> retryStrategyWithContent)Deprecated.Returns a newRetryingClientBuilder
with the specifiedRetryRuleWithContent
. -
newDecorator
Creates a newHttpClient
decorator that handles failures of an invocation and retries HTTP requests.- Parameters:
retryRule
- the retry rule
-
newDecorator
@Deprecated public static Function<? super HttpClient,RetryingClient> newDecorator(RetryStrategy retryStrategy)Deprecated.Creates a newHttpClient
decorator that handles failures of an invocation and retries HTTP requests.- Parameters:
retryStrategy
- the retry strategy
-
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
public static Function<? super HttpClient,RetryingClient> newDecorator(RetryRule retryRule, int maxTotalAttempts)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(RetryStrategy retryStrategy, int maxTotalAttempts)Deprecated.Creates a newHttpClient
decorator that handles failures of an invocation and retries HTTP requests.- Parameters:
retryStrategy
- the retry strategymaxTotalAttempts
- the maximum number of total attempts
-
newDecorator
public static Function<? super HttpClient,RetryingClient> newDecorator(RetryRuleWithContent<HttpResponse> retryRuleWithContent, int maxTotalAttempts)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
public static Function<? super HttpClient,RetryingClient> newDecorator(RetryRule retryRule, int maxTotalAttempts, long responseTimeoutMillisForEachAttempt)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(RetryStrategy retryStrategy, int maxTotalAttempts, long responseTimeoutMillisForEachAttempt)Deprecated.Creates a newHttpClient
decorator that handles failures of an invocation and retries HTTP requests.- Parameters:
retryStrategy
- the retry strategymaxTotalAttempts
- the maximum number of total attemptsresponseTimeoutMillisForEachAttempt
- response timeout for each attempt.0
disables the timeout
-
newDecorator
public static Function<? super HttpClient,RetryingClient> newDecorator(RetryRuleWithContent<HttpResponse> retryRuleWithContent, int maxTotalAttempts, long responseTimeoutMillisForEachAttempt)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
-
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
-