Class ApiRequestHandler<R extends ApiRequestHandler.RequestReader<?>,W extends ApiRequestHandler.ResponseWriter>
java.lang.Object
io.camunda.zeebe.util.sched.Actor
io.camunda.zeebe.broker.transport.ApiRequestHandler<R,W>
- Type Parameters:
R- aApiRequestHandler.RequestReaderthat reads the requestW- aApiRequestHandler.ResponseWriterthat writes the response
- All Implemented Interfaces:
RequestHandler,CloseableSilently,AsyncClosable,ConcurrencyControl,AutoCloseable
- Direct Known Subclasses:
AdminApiRequestHandler,QueryApiRequestHandler
public abstract class ApiRequestHandler<R extends ApiRequestHandler.RequestReader<?>,W extends ApiRequestHandler.ResponseWriter>
extends Actor
implements RequestHandler
A
RequestHandler that automatically decodes requests and encodes successful and error
responses.-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic interfaceApiRequestHandler.RequestReader<T extends org.agrona.sbe.MessageDecoderFlyweight>Extension ofBufferReaderthat provides extra methods used byApiRequestHandlerimplementations.static interfaceExtension ofBufferWriterthat provides extra methods used byApiRequestHandlerimplementationsNested classes/interfaces inherited from class io.camunda.zeebe.util.sched.Actor
Actor.ActorBuilder -
Field Summary
FieldsFields inherited from class io.camunda.zeebe.util.sched.Actor
actor, ACTOR_PROP_NAME, ACTOR_PROP_PARTITION_ID -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprotected abstract Either<ErrorResponseWriter,W> handle(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.util.sched.Actor
buildActorName, 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.util.sched.ConcurrencyControl
createCompletedFuture, createFuture
-
Field Details
-
LOG
public static final org.slf4j.Logger LOG
-
-
Constructor Details
-
ApiRequestHandler
-
-
Method Details
-
handle
protected abstract Either<ErrorResponseWriter,W> handle(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
-