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

    • LOG

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

    • AsyncApiRequestHandler

      protected AsyncApiRequestHandler(Supplier<R> requestReaderSupplier, Supplier<W> responseWriterSupplier)
  • 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 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