T
- type of the gatewayB
- type of the requestM
- type of the message parametersprotected abstract class AbstractAsynchronousOperationHandlers.TriggerHandler<T extends RestfulGateway,B extends RequestBody,M extends MessageParameters> extends AbstractRestHandler<T,B,TriggerResponse,M>
AbstractAsynchronousOperationHandlers.completedOperationCache
.log, MAPPER
leaderRetriever, logger, responseHeaders, timeout
Modifier | Constructor and Description |
---|---|
protected |
TriggerHandler(GatewayRetriever<? extends T> leaderRetriever,
Time timeout,
Map<String,String> responseHeaders,
MessageHeaders<B,TriggerResponse,M> messageHeaders) |
Modifier and Type | Method and Description |
---|---|
protected abstract K |
createOperationKey(HandlerRequest<B> request)
Create the operation key under which the result future of the asynchronous operation will
be stored.
|
CompletableFuture<TriggerResponse> |
handleRequest(HandlerRequest<B> request,
T gateway)
This method is called for every incoming request and returns a
CompletableFuture
containing a the response. |
protected abstract CompletableFuture<R> |
triggerOperation(HandlerRequest<B> request,
T gateway)
Trigger the asynchronous operation and return its future result.
|
getMessageHeaders, respondToRequest
closeAsync, closeHandlerAsync, 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 TriggerHandler(GatewayRetriever<? extends T> leaderRetriever, Time timeout, Map<String,String> responseHeaders, MessageHeaders<B,TriggerResponse,M> messageHeaders)
public CompletableFuture<TriggerResponse> handleRequest(@Nonnull HandlerRequest<B> 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,B extends RequestBody,TriggerResponse,M extends MessageParameters>
request
- request that should be handledgateway
- leader gatewayRestHandlerException
- if the handling failedprotected abstract CompletableFuture<R> triggerOperation(HandlerRequest<B> request, T gateway) throws RestHandlerException
request
- with which the trigger handler has been calledgateway
- to the leaderRestHandlerException
- if something went wrongprotected abstract K createOperationKey(HandlerRequest<B> request)
request
- with which the trigger handler has been called.Copyright © 2014–2024 The Apache Software Foundation. All rights reserved.