Class GrpcResponse<T>
java.lang.Object
com.codename1.io.grpc.GrpcResponse<T>
Result of a unary gRPC call. Mirrors the shape of
Response so call sites that already use
the REST helpers feel at home, but the integer status code
returned by getResponseCode() is the gRPC status, not
the HTTP one:
0--OK. Wire-level success.1..16-- standard gRPC statuses (CANCELLED, UNKNOWN, ...).-1-- the transport itself failed (network error, HTTP non-200, missing status trailer).getHttpCode()still returns the underlying HTTP code in that case.
Use isOk() for the common "request succeeded" check.
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final intstatic final intstatic final intstatic final intstatic final intstatic final intstatic final intstatic final intstatic final intstatic final intstatic final intstatic final intstatic final intstatic final intSentinel status indicating the transport itself failed (nogrpc-statustrailer was parsed).static final intstatic final intstatic final intstatic final int -
Constructor Summary
ConstructorsConstructorDescriptionGrpcResponse(int grpcStatus, int httpCode, T responseData, String responseMessage) -
Method Summary
Modifier and TypeMethodDescriptionintThe underlying HTTP status code.intThe gRPC status code.The deserialised response message, ornullwhen the call failed or the server returned an empty body.The server-suppliedgrpc-messagetrailer (or the HTTP error message when the call failed before reaching the trailer).booleanisOk()
-
Field Details
-
STATUS_OK
public static final int STATUS_OK- See Also:
-
STATUS_CANCELLED
public static final int STATUS_CANCELLED- See Also:
-
STATUS_UNKNOWN
public static final int STATUS_UNKNOWN- See Also:
-
STATUS_INVALID_ARGUMENT
public static final int STATUS_INVALID_ARGUMENT- See Also:
-
STATUS_DEADLINE_EXCEEDED
public static final int STATUS_DEADLINE_EXCEEDED- See Also:
-
STATUS_NOT_FOUND
public static final int STATUS_NOT_FOUND- See Also:
-
STATUS_ALREADY_EXISTS
public static final int STATUS_ALREADY_EXISTS- See Also:
-
STATUS_PERMISSION_DENIED
public static final int STATUS_PERMISSION_DENIED- See Also:
-
STATUS_RESOURCE_EXHAUSTED
public static final int STATUS_RESOURCE_EXHAUSTED- See Also:
-
STATUS_FAILED_PRECONDITION
public static final int STATUS_FAILED_PRECONDITION- See Also:
-
STATUS_ABORTED
public static final int STATUS_ABORTED- See Also:
-
STATUS_OUT_OF_RANGE
public static final int STATUS_OUT_OF_RANGE- See Also:
-
STATUS_UNIMPLEMENTED
public static final int STATUS_UNIMPLEMENTED- See Also:
-
STATUS_INTERNAL
public static final int STATUS_INTERNAL- See Also:
-
STATUS_UNAVAILABLE
public static final int STATUS_UNAVAILABLE- See Also:
-
STATUS_DATA_LOSS
public static final int STATUS_DATA_LOSS- See Also:
-
STATUS_UNAUTHENTICATED
public static final int STATUS_UNAUTHENTICATED- See Also:
-
STATUS_TRANSPORT_FAILURE
public static final int STATUS_TRANSPORT_FAILURESentinel status indicating the transport itself failed (nogrpc-statustrailer was parsed). InspectgetHttpCode()for the underlying HTTP error.- See Also:
-
-
Constructor Details
-
GrpcResponse
-
-
Method Details
-
getResponseData
The deserialised response message, ornullwhen the call failed or the server returned an empty body. -
getResponseCode
public int getResponseCode()The gRPC status code.0is success; non-zero codes follow the standard gRPC status enumeration.-1(STATUS_TRANSPORT_FAILURE) signals a transport-level error -- the call never reachedgrpc-status. -
getHttpCode
public int getHttpCode()The underlying HTTP status code. Usually200even for a non-zero gRPC status, because the server returns gRPC errors in trailers rather than via HTTP status. Useful whengetResponseCode()isSTATUS_TRANSPORT_FAILURE. -
isOk
public boolean isOk() -
getResponseErrorMessage
The server-suppliedgrpc-messagetrailer (or the HTTP error message when the call failed before reaching the trailer).
-