Class GrpcHelper

java.lang.Object
io.helidon.grpc.core.GrpcHelper

public final class GrpcHelper extends Object
Helper methods for common gRPC tasks.
  • Method Details

    • extractServiceName

      public static String extractServiceName(String fullMethodName)
      Extract the gRPC service name from a method full name.
      Parameters:
      fullMethodName - the gRPC method full name
      Returns:
      the service name extracted from the full name
    • extractNamePrefix

      public static String extractNamePrefix(String fullMethodName)
      Extract the name prefix from a method full name.

      The prefix is everything upto the but not including the last '/' character in the full name.

      Parameters:
      fullMethodName - the gRPC method full name
      Returns:
      the name prefix extracted from the full name
    • extractMethodName

      public static String extractMethodName(String fullMethodName)
      Extract the gRPC method name from a method full name.
      Parameters:
      fullMethodName - the gRPC method full name
      Returns:
      the method name extracted from the full name
    • toHttpResponseStatus

      public static Status toHttpResponseStatus(io.grpc.StatusException ex)
      Convert a gRPC StatusException to a Status.
      Parameters:
      ex - the gRPC StatusException to convert
      Returns:
      the gRPC StatusException converted to a Status
    • toHttpResponseStatus

      public static Status toHttpResponseStatus(io.grpc.StatusRuntimeException ex)
      Convert a gRPC StatusRuntimeException to a Status.
      Parameters:
      ex - the gRPC StatusRuntimeException to convert
      Returns:
      the gRPC StatusRuntimeException converted to a Status
    • toHttpResponseStatus

      public static Status toHttpResponseStatus(io.grpc.Status status)
      Convert a gRPC Status to a Status.
      Parameters:
      status - the gRPC Status to convert
      Returns:
      the gRPC Status converted to a Status
    • ensureStatusException

      public static Throwable ensureStatusException(Throwable thrown, io.grpc.Status status)
      Ensure that a Throwable is either a StatusRuntimeException or a StatusException.
      Parameters:
      thrown - the Throwable to test
      status - the Status to use if the Throwable has to be converted
      Returns:
      the Throwable if it is a StatusRuntimeException or a StatusException, or a new StatusException created from the specified Status with the Throwable as the cause.
    • ensureStatusRuntimeException

      public static io.grpc.StatusRuntimeException ensureStatusRuntimeException(Throwable thrown, io.grpc.Status status)
      Ensure that a Throwable is a StatusRuntimeException.
      Parameters:
      thrown - the Throwable to test
      status - the Status to use if the Throwable has to be converted
      Returns:
      the Throwable if it is a StatusRuntimeException or a new StatusRuntimeException created from the specified Status with the Throwable as the cause.