Class GrpcLifecycleObserverServiceFilter
- All Implemented Interfaces:
HttpExecutionStrategyInfluencer
,StreamingHttpServiceFilterFactory
,ExecutionStrategyInfluencer<HttpExecutionStrategy>
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 via
GrpcServerBuilder.initializeHttp(GrpcServerBuilder.HttpInitializer)
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 forGrpcLifecycleObserver.GrpcExchangeObserver
. - 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 forGrpcLifecycleObserver.GrpcExchangeObserver
. - Before any filter that maps/translates
HttpResponseMetaData
into anexception
or throws an exception duringresponse payload body transformation
if that exception has to be observed byGrpcLifecycleObserver.GrpcExchangeObserver
. - Before any exception mapping filter that maps an
exception
into a valid response, likeGrpcExceptionMapperServiceFilter
, if theGrpcLifecycleObserver.GrpcExchangeObserver
should see whatGrpcStatus
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.
GrpcLifecycleObserver
is to use
GrpcServerBuilder.lifecycleObserver(GrpcLifecycleObserver)
.-
Constructor Summary
ConstructorDescriptionCreate a new instance. -
Method Summary
Modifier and TypeMethodDescriptionfinal HttpExecutionStrategy
Return anExecutionStrategy
that describes the offloads required by the influencer.Methods inherited from class io.servicetalk.http.netty.HttpLifecycleObserverServiceFilter
create
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
-
GrpcLifecycleObserverServiceFilter
Create a new instance.- Parameters:
observer
- Theobserver
implementation that consumes gRPC lifecycle events.
-
-
Method Details
-
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.
-