Package io.servicetalk.http.utils
Class TimeoutHttpRequesterFilter
- java.lang.Object
-
- io.servicetalk.http.utils.TimeoutHttpRequesterFilter
-
- All Implemented Interfaces:
HttpExecutionStrategyInfluencer
,StreamingHttpClientFilterFactory
,StreamingHttpConnectionFilterFactory
public final class TimeoutHttpRequesterFilter extends java.lang.Object implements StreamingHttpClientFilterFactory, StreamingHttpConnectionFilterFactory
A filter to enable timeouts for HTTP requests on the client-side.The timeout applies either the response metadata (headers) completion or the complete reception of the response payload body and optional trailers.
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
Constructors Constructor Description TimeoutHttpRequesterFilter(TimeoutFromRequest timeoutForRequest, boolean fullRequestResponse)
Creates a new instance.TimeoutHttpRequesterFilter(TimeoutFromRequest timeoutForRequest, boolean fullRequestResponse, Executor timeoutExecutor)
Creates a new instance.TimeoutHttpRequesterFilter(java.time.Duration duration)
Creates a new instance which requires only that the response metadata be received before the timeout.TimeoutHttpRequesterFilter(java.time.Duration duration, boolean fullRequestResponse)
Creates a new instance.TimeoutHttpRequesterFilter(java.time.Duration duration, boolean fullRequestResponse, Executor timeoutExecutor)
Creates a new instance.TimeoutHttpRequesterFilter(java.time.Duration duration, Executor timeoutExecutor)
Creates a new instance which requires only that the response metadata be received before the timeout.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description StreamingHttpClientFilter
create(FilterableStreamingHttpClient client)
Creates aStreamingHttpClientFilter
using the providedStreamingHttpClientFilter
.StreamingHttpConnectionFilter
create(FilterableStreamingHttpConnection connection)
Create aStreamingHttpConnectionFilter
using the providedFilterableStreamingHttpConnection
.HttpExecutionStrategy
influenceStrategy(HttpExecutionStrategy strategy)
Optionally modify the passedHttpExecutionStrategy
to a newHttpExecutionStrategy
that suits thisHttpExecutionStrategyInfluencer
.-
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.StreamingHttpClientFilterFactory
append, asMultiAddressClientFilter
-
Methods inherited from interface io.servicetalk.http.api.StreamingHttpConnectionFilterFactory
append
-
-
-
-
Constructor Detail
-
TimeoutHttpRequesterFilter
public TimeoutHttpRequesterFilter(java.time.Duration duration)
Creates a new instance which requires only that the response metadata be received before the timeout.- Parameters:
duration
- the timeoutDuration
-
TimeoutHttpRequesterFilter
public TimeoutHttpRequesterFilter(java.time.Duration duration, Executor timeoutExecutor)
Creates a new instance which requires only that the response metadata be received before the timeout.- Parameters:
duration
- the timeoutDuration
timeoutExecutor
- theExecutor
to use for managing the timer notifications
-
TimeoutHttpRequesterFilter
public TimeoutHttpRequesterFilter(java.time.Duration duration, boolean fullRequestResponse)
Creates a new instance.- Parameters:
duration
- the timeoutDuration
fullRequestResponse
- iftrue
then timeout is for full request/response transaction otherwise only the response metadata must arrive before the timeout
-
TimeoutHttpRequesterFilter
public TimeoutHttpRequesterFilter(java.time.Duration duration, boolean fullRequestResponse, Executor timeoutExecutor)
Creates a new instance.- Parameters:
duration
- the timeoutDuration
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(TimeoutFromRequest 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
public TimeoutHttpRequesterFilter(TimeoutFromRequest 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 Detail
-
create
public StreamingHttpClientFilter create(FilterableStreamingHttpClient client)
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
public StreamingHttpConnectionFilter create(FilterableStreamingHttpConnection connection)
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
.
-
influenceStrategy
public final HttpExecutionStrategy influenceStrategy(HttpExecutionStrategy strategy)
Description copied from interface:HttpExecutionStrategyInfluencer
Optionally modify the passedHttpExecutionStrategy
to a newHttpExecutionStrategy
that suits thisHttpExecutionStrategyInfluencer
.- Specified by:
influenceStrategy
in interfaceHttpExecutionStrategyInfluencer
- Parameters:
strategy
-HttpExecutionStrategy
to influence.- Returns:
HttpExecutionStrategy
that suits thisHttpExecutionStrategyInfluencer
-
-