Class ForwardingReplyChannel<T>

  • Type Parameters:
    T - the message type forwarded by this ReplyChannel to the given StreamObserver
    All Implemented Interfaces:
    ReplyChannel<T>

    public class ForwardingReplyChannel<T>
    extends Object
    implements ReplyChannel<T>
    A ReplyChannel implementation which forwards the result of operations through to a StreamObserver.
    • Constructor Detail

      • ForwardingReplyChannel

        public ForwardingReplyChannel​(String instructionId,
                                      String clientId,
                                      io.grpc.stub.StreamObserver<T> stream,
                                      Function<InstructionResult,​Optional<T>> resultBuilder,
                                      Runnable onComplete)
        Construct a ForwardingReplyChannel to forward replies to the given stream.
        Parameters:
        instructionId - the instruction identifier used to send Result Messages. If the given instruction identifier is null or empty, no result will be sent
        clientId - the client identifier used to define the error location upon a completeWithError(ErrorCategory, String) invocation
        stream - the StreamObserver to forward replies of this ReplyChannel on
        resultBuilder - the builder function used to construct the InstructionResult message, used for both acknowledge the success or the failure of the operation
        onComplete - operation to perform when this ReplyChannel is completed, both successfully and exceptionally
    • Method Detail

      • send

        public void send​(T outboundMessage)
        Description copied from interface: ReplyChannel
        Sends the given outboundMessage as a reply to an incoming instruction. Where possible, the instruction identifiers should be set on the outbound message.
        Specified by:
        send in interface ReplyChannel<T>
        Parameters:
        outboundMessage - the message to send
      • complete

        public void complete()
        Description copied from interface: ReplyChannel
        Marks the inbound instruction as completed.
        Specified by:
        complete in interface ReplyChannel<T>
      • completeWithError

        public void completeWithError​(ErrorMessage errorMessage)
        Description copied from interface: ReplyChannel
        Marks the inbound instruction as exceptionally completed. The given errorMessage should provide sufficient information about the error.
        Specified by:
        completeWithError in interface ReplyChannel<T>
        Parameters:
        errorMessage - the ErrorMessage describing the error
      • completeWithError

        public void completeWithError​(ErrorCategory errorCategory,
                                      String message)
        Description copied from interface: ReplyChannel
        Marks the inbound instruction as exceptionally completed. The given errorCategory and message should provide sufficient information about the error.
        Specified by:
        completeWithError in interface ReplyChannel<T>
        Parameters:
        errorCategory - the category that best described the error encountered
        message - a message providing more details about the Error