Class TrafficResilienceHttpServiceFilter
java.lang.Object
io.servicetalk.traffic.resilience.http.TrafficResilienceHttpServiceFilter
- All Implemented Interfaces:
HttpExecutionStrategyInfluencer,StreamingHttpServiceFilterFactory,ExecutionStrategyInfluencer<HttpExecutionStrategy>
public final class TrafficResilienceHttpServiceFilter
extends Object
implements StreamingHttpServiceFilterFactory
A
StreamingHttpServiceFilterFactory to enforce capacity control for a server.
Requests that are not able to acquire a permit, will fail with a RequestDroppedException.
Ordering of filters
Ordering of thecapacity-filter is important for various reasons:
- The traffic control filter should be as early as possible in the execution chain to offer a fast-fail
reaction and ideally trigger a natural back-pressure mechanism with the transport. It's recommended to
not offload this filter by using
the
HttpServerBuilder.appendNonOffloadingServiceFilter(StreamingHttpServiceFilterFactory)variant when appending to the service builder. Therefore, it's expected that any function provided through theTrafficResilienceHttpServiceFilter.Builder, should not block, to avoid any impact on the I/O threads. since this filter will not be offloaded. - The traffic control filter should not be offloaded if possible to avoid situations where continuous traffic overflows the offloading subsystem.
- If the traffic control filter is ordered after a
timeout-filterthen a potential timeout will be delivered to it in the form of a cancellation, in which case you may want to override the defaultterminal eventof the ticket, todrop itto avail for local throttling, since a timeout is a good indicator that a sub-process in the pipeline is not completing fast enough. - If the traffic control filter is ordered before a
timeout-filterthen a potential timeout will be delivered to it in the form of aTimeoutException, which is in turn triggers thedrop-event of the ticketby default. Behavior can be overridden through thiscallback.
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic final classATrafficResilienceHttpServiceFilterinstance builder. -
Field Summary
FieldsModifier and TypeFieldDescriptionprotected static final Single<StreamingHttpResponse>protected static final Single<StreamingHttpResponse> -
Method Summary
Modifier and TypeMethodDescriptioncreate(StreamingHttpService service) Create aStreamingHttpServiceFilterusing the providedStreamingHttpService.Return anExecutionStrategythat describes the offloads required by the influencer.Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface io.servicetalk.http.api.HttpExecutionStrategyInfluencer
influenceStrategy, requiredOffloads
-
Field Details
-
DEFAULT_CAPACITY_REJECTION
-
DEFAULT_BREAKER_REJECTION
-
-
Method Details
-
create
Description copied from interface:StreamingHttpServiceFilterFactoryCreate aStreamingHttpServiceFilterusing the providedStreamingHttpService.- Specified by:
createin interfaceStreamingHttpServiceFilterFactory- Parameters:
service-StreamingHttpServiceto filter- Returns:
StreamingHttpServiceFilterusing the providedStreamingHttpService.
-
requiredOffloads
Description copied from interface:HttpExecutionStrategyInfluencerReturn anExecutionStrategythat describes the offloads required by the influencer.The provided default implementation requests offloading of all operations. Implementations that require no offloading should be careful to return
HttpExecutionStrategies.offloadNone()rather thanHttpExecutionStrategies.offloadNever(). Implementations should avoid returningHttpExecutionStrategies.defaultStrategy(), instead returning the strategy they require orHttpExecutionStrategies.offloadAll()if offloading for all paths is required (safe default).- Specified by:
requiredOffloadsin interfaceExecutionStrategyInfluencer<HttpExecutionStrategy>- Specified by:
requiredOffloadsin interfaceHttpExecutionStrategyInfluencer- Returns:
- the
ExecutionStrategyrequired by the influencer.
-