Class AsyncApiRequestHandler<R extends AsyncApiRequestHandler.RequestReader<?>,W extends AsyncApiRequestHandler.ResponseWriter>
java.lang.Object
io.camunda.zeebe.scheduler.Actor
io.camunda.zeebe.broker.transport.AsyncApiRequestHandler<R,W>
- Type Parameters:
R- aAsyncApiRequestHandler.RequestReaderthat reads the requestW- aAsyncApiRequestHandler.ResponseWriterthat writes the response
- All Implemented Interfaces:
AsyncClosable,ConcurrencyControl,RequestHandler,AutoCloseable
- Direct Known Subclasses:
AdminApiRequestHandler,BackupApiRequestHandler,QueryApiRequestHandler
public abstract class AsyncApiRequestHandler<R extends AsyncApiRequestHandler.RequestReader<?>,W extends AsyncApiRequestHandler.ResponseWriter>
extends Actor
implements RequestHandler
A
RequestHandler that automatically decodes requests and encodes successful and error
responses. Handling requests is asynchronous.-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic interfaceAsyncApiRequestHandler.RequestReader<T extends org.agrona.sbe.MessageDecoderFlyweight>Extension ofBufferReaderthat provides extra methods used byAsyncApiRequestHandlerimplementations.static interfaceExtension ofBufferWriterthat provides extra methods used byAsyncApiRequestHandlerimplementationsNested classes/interfaces inherited from class io.camunda.zeebe.scheduler.Actor
Actor.ActorBuilder -
Field Summary
FieldsFields inherited from class io.camunda.zeebe.scheduler.Actor
actor, ACTOR_PROP_NAME, ACTOR_PROP_PARTITION_ID -
Constructor Summary
ConstructorsModifierConstructorDescriptionprotectedAsyncApiRequestHandler(Supplier<R> requestReaderSupplier, Supplier<W> responseWriterSupplier) -
Method Summary
Modifier and TypeMethodDescriptionprotected abstract ActorFuture<Either<ErrorResponseWriter,W>> handleAsync(int partitionId, long requestId, R requestReader, W responseWriter, ErrorResponseWriter errorWriter) Handles a request.final voidonRequest(ServerOutput serverOutput, int partitionId, long requestId, org.agrona.DirectBuffer buffer, int offset, int length) Methods inherited from class io.camunda.zeebe.scheduler.Actor
buildActorName, close, closeAsync, createContext, getContext, getName, handleFailure, isActorClosed, newActor, onActorClosed, onActorCloseRequested, onActorClosing, onActorFailed, onActorStarted, onActorStarting, run, runOnCompletion, wrapMethods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface io.camunda.zeebe.scheduler.ConcurrencyControl
createCompletedFuture, createFuture
-
Field Details
-
LOG
public static final org.slf4j.Logger LOG
-
-
Constructor Details
-
AsyncApiRequestHandler
-
-
Method Details
-
handleAsync
protected abstract ActorFuture<Either<ErrorResponseWriter,W>> handleAsync(int partitionId, long requestId, R requestReader, W responseWriter, ErrorResponseWriter errorWriter) Handles a request. The is populated at this point.- Parameters:
partitionId- the current partition idrequestId- the current request idrequestReader- areaderthat is already populated with the request dataresponseWriter- awriterthat can be used to write successful responseserrorWriter- aErrorResponseWriterthat can be used to write error responses- Returns:
- a
ErrorResponseWriterwhen the handling failed, or aResponseWriterwhen the handling was successful. Writes to the other writer will be ignored and are not sent as a response.
-
onRequest
public final void onRequest(ServerOutput serverOutput, int partitionId, long requestId, org.agrona.DirectBuffer buffer, int offset, int length) - Specified by:
onRequestin interfaceRequestHandler
-