public final class TrafficResilienceHttpClientFilter
extends Object
implements StreamingHttpClientFilterFactory
StreamingHttpClientFilterFactory to enforce capacity and circuit-breaking control for a client.
Requests that are not able to acquire a capacity ticket or a circuit permit,
will fail with a RequestDroppedException.
capacity-filter is important for various reasons:
io.servicetalk.http.netty.RetryingHttpRequesterFilter if one is used, to avail the
benefit of retrying requests that failed due to (local or remote) capacity issues.
RetryableRequestDroppedException are safely retry-able errors, since they occur on the outgoing
side before they even touch the network. DelayedRetryRequestDroppedException errors on the other
side, are remote rejections, and its up to the application logic to opt-in for them to be retryable, by
configuring the relevant predicate of the io.servicetalk.http.netty.RetryingHttpRequesterFilterio.servicetalk.http.netty.RetryingHttpRequesterFilter to allow an already acquired
permit to be released in case
of other errors/timeouts of the operation, before retrying to re-acquire a
permit. Otherwise, a
permit may be held idle for as
long as the operation is awaiting to be re-tried, thus, mis-utilising available resources for other requests
through the same client.
timeout-filter then a potential timeout will be
delivered to it in the form of a cancellation. The default terminal callback for the ticket in that case, is
set to dropped to avail for local throttling, since a timeout is a good indicator
that a sub-process in the pipeline is not completing fast enough.
timeout-filter then a potential timeout will be
delivered to it in the form of a TimeoutException, which is in turn triggers the
drop-event of the ticket by default. Behavior can be overridden through this
TrafficResilienceHttpClientFilter.Builder.onErrorTicketTerminal(BiConsumer).
| Modifier and Type | Class and Description |
|---|---|
static class |
TrafficResilienceHttpClientFilter.Builder
A
TrafficResilienceHttpServiceFilter instance builder. |
| Modifier and Type | Field and Description |
|---|---|
protected static Single<StreamingHttpResponse> |
DEFAULT_BREAKER_REJECTION |
static Predicate<HttpResponseMetaData> |
DEFAULT_BREAKER_REJECTION_PREDICATE
Default rejection observer for dropped requests from an external sourced due to service unavailability.
|
protected static Single<StreamingHttpResponse> |
DEFAULT_CAPACITY_REJECTION |
| Modifier and Type | Method and Description |
|---|---|
StreamingHttpClientFilter |
create(FilterableStreamingHttpClient client) |
HttpExecutionStrategy |
requiredOffloads() |
public static final Predicate<HttpResponseMetaData> DEFAULT_BREAKER_REJECTION_PREDICATE
peerBreakerRejection(HttpResponseMetaData, CircuitBreaker, Function).
The default predicate matches the following HTTP response codes:
HttpResponseStatus.SERVICE_UNAVAILABLEprotected static final Single<StreamingHttpResponse> DEFAULT_CAPACITY_REJECTION
protected static final Single<StreamingHttpResponse> DEFAULT_BREAKER_REJECTION
public StreamingHttpClientFilter create(FilterableStreamingHttpClient client)
create in interface StreamingHttpClientFilterFactorypublic HttpExecutionStrategy requiredOffloads()
requiredOffloads in interface HttpExecutionStrategyInfluencerrequiredOffloads in interface ExecutionStrategyInfluencer<HttpExecutionStrategy>