Class EventsReceiverServiceAdditions

java.lang.Object
com.atlassian.bamboo.grpc.receiver.EventsReceiverServiceAdditions

public class EventsReceiverServiceAdditions extends Object
Utility class providing helper methods for handling gRPC event receiver services. These methods facilitate common tasks such as creating responses, handling responses to stream observers, reducing execution results to statuses, and logging request messages.
  • Constructor Details

    • EventsReceiverServiceAdditions

      public EventsReceiverServiceAdditions()
  • Method Details

    • createResponse

      Creates a gRPC CommonResponse with the specified status.
      Parameters:
      status - The status to set in the response.
      Returns:
      A CommonResponse with the given status.
    • getFailedCommonResponse

      public static CrossNodesCommunication.CommonResponse getFailedCommonResponse()
      Creates a gRPC CommonResponse with a failure status.
      Returns:
      A CommonResponse with the status set to FAILURE.
    • returnResponseAndComplete

      public static <T> void returnResponseAndComplete(io.grpc.stub.StreamObserver<T> responseObserver, T response)
      Sends a response and completes the stream observer.
      Type Parameters:
      T - The type of the response.
      Parameters:
      responseObserver - The StreamObserver to send the response to.
      response - The response to send.
    • reduceResultsToStatus

      @VisibleForTesting public static CrossNodesCommunication.ResultStatus.Status reduceResultsToStatus(List<Pair<Long,Long>> input)
      Returns:
      The full execution status based on the results of the partial executions. The execution error on the remote side is handled by the dead letter queue. In this gRPC implementation, if the transport layer fails we end up with the `onError`. However, if anything related to business logic fails, we always finish the request successfully with the 'onCompleted'. The 'real' execution status is evaluated with the function below and returned as a payload.
    • logRequestMessage

      public static <T> void logRequestMessage(T message, org.apache.logging.log4j.Logger log)
      Logs a request message if debug logging is enabled.
      Type Parameters:
      T - The type of the message.
      Parameters:
      message - The message to log.
      log - The Logger instance to use for logging.