Class TimeoutHttpServiceFilter

  • All Implemented Interfaces:
    HttpExecutionStrategyInfluencer, StreamingHttpServiceFilterFactory

    public final class TimeoutHttpServiceFilter
    extends java.lang.Object
    implements StreamingHttpServiceFilterFactory
    A filter to enable timeouts for HTTP requests on the server-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 Detail

      • TimeoutHttpServiceFilter

        public TimeoutHttpServiceFilter​(java.time.Duration duration)
        Creates a new instance which requires only that the response metadata be received before the timeout.
        Parameters:
        duration - the timeout Duration
      • TimeoutHttpServiceFilter

        public TimeoutHttpServiceFilter​(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 timeout Duration
        timeoutExecutor - the Executor to use for managing the timer notifications
      • TimeoutHttpServiceFilter

        public TimeoutHttpServiceFilter​(java.time.Duration duration,
                                        boolean fullRequestResponse)
        Creates a new instance.
        Parameters:
        duration - the timeout Duration
        fullRequestResponse - if true then timeout is for full request/response transaction otherwise only the response metadata must arrive before the timeout
      • TimeoutHttpServiceFilter

        public TimeoutHttpServiceFilter​(java.time.Duration duration,
                                        boolean fullRequestResponse,
                                        Executor timeoutExecutor)
        Creates a new instance.
        Parameters:
        duration - the timeout Duration
        fullRequestResponse - if true then timeout is for full request/response transaction otherwise only the response metadata must arrive before the timeout
        timeoutExecutor - the Executor to use for managing the timer notifications
      • TimeoutHttpServiceFilter

        public TimeoutHttpServiceFilter​(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 return null
        fullRequestResponse - if true then timeout is for full request/response transaction otherwise only the response metadata must arrive before the timeout
      • TimeoutHttpServiceFilter

        public TimeoutHttpServiceFilter​(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 return null
        fullRequestResponse - if true then timeout is for full request/response transaction otherwise only the response metadata must arrive before the timeout
        timeoutExecutor - the Executor to use for managing the timer notifications