Class PipelinedChannel<REQ,RESP>

java.lang.Object
io.bytestreams.exchange.core.AbstractChannel<REQ,RESP>
io.bytestreams.exchange.core.PipelinedChannel<REQ,RESP>
Type Parameters:
REQ - the request message type
RESP - the response message type
All Implemented Interfaces:
Channel, ClientChannel<REQ,RESP>

public class PipelinedChannel<REQ,RESP> extends AbstractChannel<REQ,RESP>
A ClientChannel backed by a Transport using positional (pipelined) correlation.

Responses are matched to requests in FIFO order. Supports bounded concurrency (backpressure). Set maxConcurrency=1 for lockstep (one in-flight request at a time).

  • Field Details

    • tracer

      protected final io.opentelemetry.api.trace.Tracer tracer
    • writeLock

      protected final Object writeLock
    • errorHandler

      protected final ErrorHandler<REQ,RESP> errorHandler
  • Method Details

    • builder

      public static <REQ, RESP> PipelinedChannel.Builder<REQ,RESP> builder()
    • onInbound

      protected void onInbound(RESP response)
      Specified by:
      onInbound in class AbstractChannel<REQ,RESP>
    • hasPending

      protected boolean hasPending()
      Specified by:
      hasPending in class AbstractChannel<REQ,RESP>
    • request

      public CompletableFuture<RESP> request(REQ request)
      Description copied from interface: ClientChannel
      Sends a message using the channel's configured default timeout and returns a future that completes when a correlated response arrives.
      Specified by:
      request in interface ClientChannel<REQ,RESP>
      Parameters:
      request - the message to send
      Returns:
      a future that completes with the correlated response
    • request

      public CompletableFuture<RESP> request(REQ request, Duration timeout)
      Description copied from interface: ClientChannel
      Sends a message with a per-request timeout override.
      Specified by:
      request in interface ClientChannel<REQ,RESP>
      Parameters:
      request - the message to send
      timeout - the timeout for this request; must be positive
      Returns:
      a future that completes with the correlated response