Class TimeoutHttpRequesterFilter
- All Implemented Interfaces:
HttpExecutionStrategyInfluencer
,StreamingHttpClientFilterFactory
,StreamingHttpConnectionFilterFactory
,ExecutionStrategyInfluencer<HttpExecutionStrategy>
The timeout applies either the response metadata (headers) completion or the complete reception of the response payload body and optional trailers.
If no executor is specified at construction an executor from HttpExecutionContext
associated with the
client or connection will be used. If the HttpExecutionContext.executionStrategy()
specifies an
HttpExecutionStrategy
with offloads then ExecutionContext.executor()
will be used and if no
offloads are specified then ExecutionContext.ioExecutor()
will be used.
The order with which this filter is applied may be highly significant. For example, appending it before a retry filter would have different results than applying it after the retry filter; timeout would apply for all retries vs timeout per retry.
-
Constructor Summary
ConstructorDescriptionTimeoutHttpRequesterFilter
(TimeoutFromRequest timeoutForRequest, boolean fullRequestResponse) Deprecated.TimeoutHttpRequesterFilter
(TimeoutFromRequest timeoutForRequest, boolean fullRequestResponse, Executor timeoutExecutor) Deprecated.TimeoutHttpRequesterFilter
(Duration duration) Creates a new instance which requires only that the response metadata be received before the timeout.TimeoutHttpRequesterFilter
(Duration duration, boolean fullRequestResponse) Creates a new instance.TimeoutHttpRequesterFilter
(Duration duration, boolean fullRequestResponse, Executor timeoutExecutor) Creates a new instance.TimeoutHttpRequesterFilter
(Duration duration, Executor timeoutExecutor) Creates a new instance which requires only that the response metadata be received before the timeout.TimeoutHttpRequesterFilter
(BiFunction<HttpRequestMetaData, TimeSource, Duration> timeoutForRequest, boolean fullRequestResponse) Creates a new instance.TimeoutHttpRequesterFilter
(BiFunction<HttpRequestMetaData, TimeSource, Duration> timeoutForRequest, boolean fullRequestResponse, Executor timeoutExecutor) Creates a new instance. -
Method Summary
Modifier and TypeMethodDescriptioncreate
(FilterableStreamingHttpClient client) Creates aStreamingHttpClientFilter
using the providedStreamingHttpClientFilter
.create
(FilterableStreamingHttpConnection connection) Create aStreamingHttpConnectionFilter
using the providedFilterableStreamingHttpConnection
.final HttpExecutionStrategy
Return anExecutionStrategy
that describes the offloads required by the influencer.Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Methods inherited from interface io.servicetalk.http.api.HttpExecutionStrategyInfluencer
influenceStrategy, requiredOffloads
-
Constructor Details
-
TimeoutHttpRequesterFilter
Creates a new instance which requires only that the response metadata be received before the timeout.- Parameters:
duration
- the timeoutDuration
, must be> 0
-
TimeoutHttpRequesterFilter
Creates a new instance which requires only that the response metadata be received before the timeout. -
TimeoutHttpRequesterFilter
Creates a new instance.- Parameters:
duration
- the timeoutDuration
, must be> 0
fullRequestResponse
- iftrue
then timeout is for full request/response transaction otherwise only the response metadata must arrive before the timeout
-
TimeoutHttpRequesterFilter
public TimeoutHttpRequesterFilter(Duration duration, boolean fullRequestResponse, Executor timeoutExecutor) Creates a new instance. -
TimeoutHttpRequesterFilter
@Deprecated public TimeoutHttpRequesterFilter(TimeoutFromRequest timeoutForRequest, boolean fullRequestResponse) Deprecated.Creates a new instance.- Parameters:
timeoutForRequest
- function for extracting timeout from request which may also determine the timeout using other sources. If no timeout is to be applied then the function should returnnull
fullRequestResponse
- iftrue
then timeout is for full request/response transaction otherwise only the response metadata must arrive before the timeout
-
TimeoutHttpRequesterFilter
public TimeoutHttpRequesterFilter(BiFunction<HttpRequestMetaData, TimeSource, Duration> timeoutForRequest, boolean fullRequestResponse) Creates a new instance.- Parameters:
timeoutForRequest
- function for extracting timeout from request which may also determine the timeout using other sources. If no timeout is to be applied then the function should returnnull
fullRequestResponse
- iftrue
then timeout is for full request/response transaction otherwise only the response metadata must arrive before the timeout
-
TimeoutHttpRequesterFilter
@Deprecated public TimeoutHttpRequesterFilter(TimeoutFromRequest timeoutForRequest, boolean fullRequestResponse, Executor timeoutExecutor) Deprecated.Creates a new instance.- Parameters:
timeoutForRequest
- function for extracting timeout from request which may also determine the timeout using other sources. If no timeout is to be applied then the function should returnnull
fullRequestResponse
- iftrue
then timeout is for full request/response transaction otherwise only the response metadata must arrive before the timeouttimeoutExecutor
- theExecutor
to use for managing the timer notifications
-
TimeoutHttpRequesterFilter
public TimeoutHttpRequesterFilter(BiFunction<HttpRequestMetaData, TimeSource, Duration> timeoutForRequest, boolean fullRequestResponse, Executor timeoutExecutor) Creates a new instance.- Parameters:
timeoutForRequest
- function for extracting timeout from request which may also determine the timeout using other sources. If no timeout is to be applied then the function should returnnull
fullRequestResponse
- iftrue
then timeout is for full request/response transaction otherwise only the response metadata must arrive before the timeouttimeoutExecutor
- theExecutor
to use for managing the timer notifications
-
-
Method Details
-
create
Description copied from interface:StreamingHttpClientFilterFactory
Creates aStreamingHttpClientFilter
using the providedStreamingHttpClientFilter
.- Specified by:
create
in interfaceStreamingHttpClientFilterFactory
- Parameters:
client
-FilterableStreamingHttpClient
to filter- Returns:
StreamingHttpClientFilter
using the providedStreamingHttpClientFilter
.
-
create
Description copied from interface:StreamingHttpConnectionFilterFactory
Create aStreamingHttpConnectionFilter
using the providedFilterableStreamingHttpConnection
.- Specified by:
create
in interfaceStreamingHttpConnectionFilterFactory
- Parameters:
connection
-FilterableStreamingHttpConnection
to filter- Returns:
StreamingHttpConnectionFilter
using the providedFilterableStreamingHttpConnection
.
-
requiredOffloads
Description copied from interface:HttpExecutionStrategyInfluencer
Return anExecutionStrategy
that 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:
requiredOffloads
in interfaceExecutionStrategyInfluencer<HttpExecutionStrategy>
- Specified by:
requiredOffloads
in interfaceHttpExecutionStrategyInfluencer
- Returns:
- the
ExecutionStrategy
required by the influencer.
-
TimeoutHttpRequesterFilter(BiFunction, boolean)
.