Chapter 11 – gRPC-Based API Development and Testing
- Because, unlike HTTP libraries, gRPC libraries also provide the following features:
a. Interaction with flow control at the application layer
b. Cascading call cancellation
c. Load balancing and failover
- Yes, we can. You can use the metadata as shown in the next code block. However, making use of
com.google.rpc.Status
allows you to use thedetails
(with a type ofAny
) object, which can capture more information:Metadata.Key<SourceId.Response> key = Â Â Â Â ProtoUtils.keyForProto(SourceId.Response.getDefaultInstance); Metadata metadata = new Metadata(); metadata.put(key, sourceIdResponse); respObserver.onError(Status.INVALID_ARGUMENT Â Â Â .withDescription("Invalid Source ID") Â Â Â .asRuntimeException(metadata));
com.google.rpc.Status
can include details of typeAny
, which can be used to provide more error details.io.grpc.Status
does not have a field that...