public interface DeferredAction
Interface for processing deferred responses from the server.
This interfaces is used in protocol 11 or higher.
- Since:
- 3.0
- Author:
- Mark Rotteveel
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final DeferredActionAn instance ofDeferredActionwhich does nothing (uses the default methods of this interface). -
Method Summary
Modifier and TypeMethodDescriptiondefault WarningMessageCallbackWarning message callback.default voidonException(Exception exception) Exception received when receiving or processing the response.default voidprocessResponse(Response response) Steps to process the deferred response.default booleanIndicates if this deferred action cannot be processed without an explicit sync action (e.g.static <T> DeferredActionwrapDeferredResponse(DeferredResponse<T> deferredResponse, Function<Response, T> responseMapper, WarningMessageCallback warningMessageCallback, Consumer<Exception> exceptionConsumer, boolean requiresSync) Wraps aDeferredResponsein aDeferredAction.
-
Field Details
-
NO_OP_INSTANCE
An instance ofDeferredActionwhich does nothing (uses the default methods of this interface).
-
-
Method Details
-
processResponse
Steps to process the deferred response.The default implementation does nothing.
- Parameters:
response- Response object.
-
onException
Exception received when receiving or processing the response.The default implementation only logs the exception on debug level.
- Parameters:
exception- exception received processing the response- Since:
- 5
-
getWarningMessageCallback
Warning message callback.The default implementation returns
null.- Returns:
- warning callback to use when executing this deferred action,
nullsignals to use the default
-
requiresSync
default boolean requiresSync()Indicates if this deferred action cannot be processed without an explicit sync action (e.g.op_pingorop_batch_sync). Should also be used for requests which haven't been explicitly flushed.Failure to perform such a sync action may result in indefinitely blocking on read.
- Returns:
trueif this deferred action requires an explicit sync action- Since:
- 6
-
wrapDeferredResponse
static <T> DeferredAction wrapDeferredResponse(DeferredResponse<T> deferredResponse, Function<Response, T> responseMapper, WarningMessageCallback warningMessageCallback, Consumer<Exception> exceptionConsumer, boolean requiresSync) Wraps aDeferredResponsein aDeferredAction.- Type Parameters:
T- response type of the deferred response- Parameters:
deferredResponse- the deferred response to wrapresponseMapper- conversion from aResponseto the appropriate object (ornull) to call onDeferredResponse.onResponse(Object)warningMessageCallback- warning message callback to use when receiving the responseexceptionConsumer- action to take for exceptions- Returns:
- deferred action
-