Class RetryingHttpClientBuilder
- java.lang.Object
-
- com.linecorp.armeria.client.retry.RetryingClientBuilder<RetryingHttpClientBuilder,RetryingHttpClient,HttpRequest,HttpResponse>
-
- com.linecorp.armeria.client.retry.RetryingHttpClientBuilder
-
public class RetryingHttpClientBuilder extends RetryingClientBuilder<RetryingHttpClientBuilder,RetryingHttpClient,HttpRequest,HttpResponse>
Builds a newRetryingHttpClient
or its decorator function.
-
-
Constructor Summary
Constructors Constructor Description RetryingHttpClientBuilder(RetryStrategy retryStrategy)
Creates a new builder with the specifiedRetryStrategy
.RetryingHttpClientBuilder(RetryStrategyWithContent<HttpResponse> retryStrategyWithContent)
Creates a new builder with the specifiedRetryStrategyWithContent
.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description RetryingHttpClient
build(Client<HttpRequest,HttpResponse> delegate)
Returns a newly-createdRetryingHttpClient
based on the properties of this builder.RetryingHttpClientBuilder
contentPreviewLength(int contentPreviewLength)
Sets the length of content required to determine whether to retry or not.Function<Client<HttpRequest,HttpResponse>,RetryingHttpClient>
newDecorator()
Returns a newly-created decorator that decorates aClient
with a newRetryingHttpClient
based on the properties of this builder.String
toString()
RetryingHttpClientBuilder
useRetryAfter(boolean useRetryAfter)
Whether retry should be attempted according to theretryHeader
from the server or not.-
Methods inherited from class com.linecorp.armeria.client.retry.RetryingClientBuilder
maxTotalAttempts, responseTimeoutForEachAttempt, responseTimeoutMillisForEachAttempt
-
-
-
-
Constructor Detail
-
RetryingHttpClientBuilder
public RetryingHttpClientBuilder(RetryStrategy retryStrategy)
Creates a new builder with the specifiedRetryStrategy
.
-
RetryingHttpClientBuilder
public RetryingHttpClientBuilder(RetryStrategyWithContent<HttpResponse> retryStrategyWithContent)
Creates a new builder with the specifiedRetryStrategyWithContent
.
-
-
Method Detail
-
useRetryAfter
public RetryingHttpClientBuilder useRetryAfter(boolean useRetryAfter)
Whether retry should be attempted according to theretryHeader
from the server or not. The web server may request a client to retry after specific time withretryAfter
header. If you want to follow the direction from the server not by yourBackoff
, invoke this method with theuseRetryAfter
withtrue
to request after the specified delay.- Parameters:
useRetryAfter
-true
if you want to retry after using theretryAfter
header.false
otherwise- Returns:
RetryingHttpClientBuilder
to support method chaining
-
contentPreviewLength
public RetryingHttpClientBuilder contentPreviewLength(int contentPreviewLength)
Sets the length of content 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. Note that this property is useful only if you specifiedRetryStrategyWithContent
when calling this builder's constructor. The default value of this property is 2147483647.- Parameters:
contentPreviewLength
- the content length to preview.0
does not disable the length limit.- Returns:
RetryingHttpClientBuilder
to support method chaining- Throws:
IllegalStateException
- if this builder is created with aRetryStrategy
rather thanRetryStrategyWithContent
IllegalArgumentException
- if the specifiedcontentPreviewLength
is equal to or less than0
-
build
public RetryingHttpClient build(Client<HttpRequest,HttpResponse> delegate)
Returns a newly-createdRetryingHttpClient
based on the properties of this builder.
-
newDecorator
public Function<Client<HttpRequest,HttpResponse>,RetryingHttpClient> newDecorator()
Returns a newly-created decorator that decorates aClient
with a newRetryingHttpClient
based on the properties of this builder.
-
toString
public String toString()
- Overrides:
toString
in classRetryingClientBuilder<RetryingHttpClientBuilder,RetryingHttpClient,HttpRequest,HttpResponse>
-
-