java.lang.Object
io.camunda.zeebe.util.sched.Actor
io.camunda.zeebe.broker.transport.ApiRequestHandler<R,W>
Type Parameters:
R - a ApiRequestHandler.RequestReader that reads the request
W - a ApiRequestHandler.ResponseWriter that 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.
  • Field Details

    • LOG

      public static final org.slf4j.Logger LOG
  • Constructor Details

    • ApiRequestHandler

      protected ApiRequestHandler(R requestReader, W responseWriter)
  • 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 id
      requestId - the current request id
      requestReader - a reader that is already populated with the request data
      responseWriter - a writer that can be used to write successful responses
      errorWriter - a ErrorResponseWriter that can be used to write error responses
      Returns:
      a ErrorResponseWriter when the handling failed, or a ResponseWriter when 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:
      onRequest in interface RequestHandler