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 DeferredAction
An instance ofDeferredAction
which does nothing (uses the default methods of this interface). -
Method Summary
Modifier and TypeMethodDescriptiondefault WarningMessageCallback
Warning message callback.default void
onException
(Exception exception) Exception received when receiving or processing the response.default void
processResponse
(Response response) Steps to process the deferred response.default boolean
Indicates if this deferred action cannot be processed without an explicit sync action (e.g.static <T> DeferredAction
wrapDeferredResponse
(DeferredResponse<T> deferredResponse, Function<Response, T> responseMapper, WarningMessageCallback warningMessageCallback, Consumer<Exception> exceptionConsumer, boolean requiresSync) Wraps aDeferredResponse
in aDeferredAction
.
-
Field Details
-
NO_OP_INSTANCE
An instance ofDeferredAction
which 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,
null
signals to use the default
-
requiresSync
default boolean requiresSync()Indicates if this deferred action cannot be processed without an explicit sync action (e.g.op_ping
orop_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:
true
if 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 aDeferredResponse
in aDeferredAction
.- Type Parameters:
T
- response type of the deferred response- Parameters:
deferredResponse
- the deferred response to wrapresponseMapper
- conversion from aResponse
to 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
-