Class HttpLifecycleObserverServiceFilter
- All Implemented Interfaces:
HttpExecutionStrategyInfluencer
,StreamingHttpServiceFilterFactory
,ExecutionStrategyInfluencer<HttpExecutionStrategy>
- Direct Known Subclasses:
GrpcLifecycleObserverServiceFilter
The result of the observed behavior will depend on the position of this filter in the execution chain.
This filter is recommended to be appended as one of the first filters using
HttpServerBuilder.appendNonOffloadingServiceFilter(StreamingHttpServiceFilterFactory)
method to account for
all work done by other filters and offloading of the requests processing. It can be appended at another position,
considering the following:
- After a tracing filter or any other filter that populates
request context
,AsyncContext
,MDC
, or altersHttpRequestMetaData
if that information has to be available forHttpLifecycleObserver.HttpExchangeObserver
. - After
TimeoutHttpRequesterFilter
if the timeout event should be observed ascancellation
instead of anerror
. - After any filter that can reject requests, like
BasicAuthHttpServiceFilter
, if only allowed requests should be observed. - Before any filter that can reject requests, like
BasicAuthHttpServiceFilter
, if all incoming requests have to be observed. - Before any filter that populates
response context
or altersHttpResponseMetaData
if that information has to be available forHttpLifecycleObserver.HttpExchangeObserver
. - Before any filter that maps/translates
HttpResponseMetaData
into anexception
or throws an exception duringresponse payload body transformation
if that exception has to be observed byHttpLifecycleObserver.HttpExchangeObserver
. - Before any exception mapping filter that maps an
exception
into a valid response, likeHttpExceptionMapperServiceFilter
, if theHttpLifecycleObserver.HttpExchangeObserver
should see what status code is returned to the client. - Using
HttpServerBuilder.appendServiceFilter(StreamingHttpServiceFilterFactory)
if an exchange should be observed after it's offloaded from anIoExecutor
(if offloading is enabled). - Using
HttpServerBuilder.appendNonOffloadingServiceFilter(Predicate, StreamingHttpServiceFilterFactory)
orHttpServerBuilder.appendServiceFilter(Predicate, StreamingHttpServiceFilterFactory)
if the observer should be applied conditionally. - As the last
HttpServerBuilder.appendServiceFilter(StreamingHttpServiceFilterFactory)
if only service business logic should be observed without accounting for work of any other filters.
HttpLifecycleObserver
is to use
HttpServerBuilder.lifecycleObserver(HttpLifecycleObserver)
.-
Constructor Summary
ConstructorDescriptionCreate a new instance. -
Method Summary
Modifier and TypeMethodDescriptioncreate
(StreamingHttpService service) Create aStreamingHttpServiceFilter
using the providedStreamingHttpService
.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
-
HttpLifecycleObserverServiceFilter
Create a new instance.- Parameters:
observer
- Theobserver
implementation that consumes HTTP lifecycle events.
-
-
Method Details
-
create
Description copied from interface:StreamingHttpServiceFilterFactory
Create aStreamingHttpServiceFilter
using the providedStreamingHttpService
.- Specified by:
create
in interfaceStreamingHttpServiceFilterFactory
- Parameters:
service
-StreamingHttpService
to filter- Returns:
StreamingHttpServiceFilter
using the providedStreamingHttpService
.
-
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.
-