Interface HttpLifecycleObserver.HttpExchangeObserver
- All Known Subinterfaces:
GrpcLifecycleObserver.GrpcExchangeObserver
- Enclosing interface:
- HttpLifecycleObserver
An exchange is represented by a request and a response.
Both can be observed independently via their corresponding observers and may publish their events concurrently
with each other because connections are full-duplex. The final event for the
exchange is signaled only after both nested observers terminate. It guarantees visibility of both observers
internal states inside the final callback.
-
Method Summary
Modifier and TypeMethodDescriptiondefault voidCallback when a connection is selected for this exchange execution.default voidCallback when the exchange completes.onRequest(HttpRequestMetaData requestMetaData) Callback when a request starts.onResponse(HttpResponseMetaData responseMetaData) Callback when a response meta-data was observed.default voidCallback if the response meta-data was cancelled.default voidonResponseError(Throwable cause) Callback if the response meta-data was not received due to an error.
-
Method Details
-
onConnectionSelected
Callback when a connection is selected for this exchange execution.- Parameters:
info-ConnectionInfoof the selected connection
-
onRequest
Callback when a request starts.- Parameters:
requestMetaData- The correspondingHttpRequestMetaData- Returns:
- an
HttpLifecycleObserver.HttpRequestObserverthat provides visibility into request events
-
onResponse
default HttpLifecycleObserver.HttpResponseObserver onResponse(HttpResponseMetaData responseMetaData) Callback when a response meta-data was observed.Either this or
onResponseError(Throwable)callback can be invoked, but not both.- Parameters:
responseMetaData- the correspondingHttpResponseMetaData- Returns:
- an
HttpLifecycleObserver.HttpResponseObserverthat provides visibility into response events
-
onResponseError
Callback if the response meta-data was not received due to an error.Either this or
onResponse(HttpResponseMetaData)callback can be invoked, but not both.- Parameters:
cause- the cause of a response meta-data failure
-
onResponseCancel
default void onResponseCancel()Callback if the response meta-data was cancelled.Cancellation is the best effort, more events may be signaled after cancel.
-
onExchangeFinally
default void onExchangeFinally()Callback when the exchange completes.This is the final callback that is invoked after
HttpLifecycleObserver.HttpRequestObserverterminates and eitherHttpLifecycleObserver.HttpResponseObserverterminates oronResponseError(Throwable)/onResponseCancel()method is invoked. Inside this callback, users can safely consume the internal state of all other callbacks without the need for additional synchronization.
-