T
- type of the leader gatewayV
- type of the operation resultM
- type of the message headersprotected abstract class AbstractAsynchronousOperationHandlers.StatusHandler<T extends RestfulGateway,V,M extends MessageParameters> extends AbstractRestHandler<T,EmptyRequestBody,AsynchronousOperationResult<V>,M>
AsynchronousOperationResult
which indicates whether the operation is still
in progress or has completed. In case that the operation has been completed, the AsynchronousOperationResult
contains the operation result.log, MAPPER
leaderRetriever, logger, responseHeaders, timeout
Modifier | Constructor and Description |
---|---|
protected |
StatusHandler(GatewayRetriever<? extends T> leaderRetriever,
Time timeout,
Map<String,String> responseHeaders,
MessageHeaders<EmptyRequestBody,AsynchronousOperationResult<V>,M> messageHeaders) |
Modifier and Type | Method and Description |
---|---|
CompletableFuture<Void> |
closeHandlerAsync() |
protected abstract V |
exceptionalOperationResultResponse(Throwable throwable)
Create an exceptional operation result from the given
Throwable . |
protected abstract K |
getOperationKey(HandlerRequest<EmptyRequestBody,M> request)
Extract the operation key under which the operation result future is stored.
|
CompletableFuture<AsynchronousOperationResult<V>> |
handleRequest(HandlerRequest<EmptyRequestBody,M> request,
T gateway)
This method is called for every incoming request and returns a
CompletableFuture
containing a the response. |
protected abstract V |
operationResultResponse(R operationResult)
Create the operation result from the given value.
|
getMessageHeaders, respondToRequest
closeAsync, respondAsLeader
channelRead0
acceptInboundMessage, channelRead
channelActive, channelInactive, channelReadComplete, channelRegistered, channelUnregistered, channelWritabilityChanged, exceptionCaught, userEventTriggered
ensureNotSharable, handlerAdded, handlerRemoved, isSharable
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
close
protected StatusHandler(GatewayRetriever<? extends T> leaderRetriever, Time timeout, Map<String,String> responseHeaders, MessageHeaders<EmptyRequestBody,AsynchronousOperationResult<V>,M> messageHeaders)
public CompletableFuture<AsynchronousOperationResult<V>> handleRequest(@Nonnull HandlerRequest<EmptyRequestBody,M> request, @Nonnull T gateway) throws RestHandlerException
AbstractRestHandler
CompletableFuture
containing a the response.
Implementations may decide whether to throw RestHandlerException
s or fail the
returned CompletableFuture
with a RestHandlerException
.
Failing the future with another exception type or throwing unchecked exceptions is
regarded as an implementation error as it does not allow us to provide a meaningful HTTP
status code. In this case a HttpResponseStatus.INTERNAL_SERVER_ERROR
will be
returned.
handleRequest
in class AbstractRestHandler<T extends RestfulGateway,EmptyRequestBody,AsynchronousOperationResult<V>,M extends MessageParameters>
request
- request that should be handledgateway
- leader gatewayRestHandlerException
- if the handling failedpublic CompletableFuture<Void> closeHandlerAsync()
closeHandlerAsync
in class AbstractHandler<T extends RestfulGateway,EmptyRequestBody,M extends MessageParameters>
protected abstract K getOperationKey(HandlerRequest<EmptyRequestBody,M> request)
request
- with which the status handler has been calledprotected abstract V exceptionalOperationResultResponse(Throwable throwable)
Throwable
. This method is
called if the asynchronous operation failed.throwable
- failure of the asynchronous operationCopyright © 2014–2021 The Apache Software Foundation. All rights reserved.