Interface FlightServerMiddleware

All Known Implementing Classes:
ServerCallHeaderAuthMiddleware, ServerHeaderMiddleware, ServerSessionMiddleware

public interface FlightServerMiddleware
Server-side middleware for Flight calls.

Middleware are instantiated per-call.

Methods are not guaranteed to be called on any particular thread, relative to the thread that Flight requests are executed on. Do not depend on thread-local storage; instead, use state on the middleware instance. Service implementations may communicate with middleware implementations through FlightProducer.CallContext.getMiddleware(Key). Methods on the middleware instance are non-reentrant, that is, a particular RPC will not make multiple concurrent calls to methods on a single middleware instance. However, methods on the factory instance are expected to be thread-safe, and if the factory instance returns the same middleware object more than once, then that middleware object must be thread-safe.

  • Method Details

    • onBeforeSendingHeaders

      void onBeforeSendingHeaders(CallHeaders outgoingHeaders)
      Callback for when the underlying transport is about to send response headers.
      Parameters:
      outgoingHeaders - A mutable set of response headers. These can be manipulated to send different headers to the client.
    • onCallCompleted

      void onCallCompleted(CallStatus status)
      Callback for when the underlying transport has completed a call.
      Parameters:
      status - Whether the call completed successfully or not.
    • onCallErrored

      void onCallErrored(Throwable err)
      Callback for when an RPC method implementation throws an uncaught exception.

      May be called multiple times, and may be called before or after onCallCompleted(CallStatus). Generally, an uncaught exception will end the call with a error CallStatus, and will be reported to onCallCompleted(CallStatus), but not necessarily this method.

      Parameters:
      err - The exception that was thrown.