@BetaApi(value="The surface for response metadata is not stable yet and may change in the future.") public class GrpcResponseMetadata extends Object implements ResponseMetadataHandler
NOTE: the GrpcResponseMetadata class is not thread-safe and should NOT be re-used for multiple calls. A new instance of GrpcResponseMetadata should be constructed for each call that requires metadata to be accessed.
Example usage:
GrpcResponseMetadata grpcResponseMetadata = new GrpcResponseMetadata();
Foo foo = client.getFooCallable().call(getFooRequest, grpcResponseMetadata.createContextWithHandlers());
Metadata headers = grpcResponseMetadata.getMetadata();
Metadata trailers = grpcResponseMetadata.getTrailingMetadata();
| Constructor and Description |
|---|
GrpcResponseMetadata() |
| Modifier and Type | Method and Description |
|---|---|
GrpcCallContext |
addHandlers(com.google.api.gax.rpc.ApiCallContext apiCallContext)
Constructs a new call context from an existing ApiCallContext, and sets the CallOptions to add
handlers to retrieve the headers and trailers, and make them available via the getMetadata and
getTrailingMetadata methods.
|
GrpcCallContext |
createContextWithHandlers()
Constructs a new call context and sets the CallOptions to add handlers to retrieve the headers
and trailers, and make them available via the getMetadata and getTrailingMetadata methods.
|
io.grpc.Metadata |
getMetadata()
Returns the headers from the gRPC method as Metadata.
|
io.grpc.Metadata |
getTrailingMetadata()
Returns the trailers from the gRPC method as Metadata.
|
void |
onHeaders(io.grpc.Metadata metadata)
Handle the headers returned by an RPC.
|
void |
onTrailers(io.grpc.Metadata metadata)
Handle the trailers returned by an RPC.
|
public GrpcCallContext addHandlers(com.google.api.gax.rpc.ApiCallContext apiCallContext)
public GrpcCallContext createContextWithHandlers()
public io.grpc.Metadata getMetadata()
public io.grpc.Metadata getTrailingMetadata()
public void onHeaders(io.grpc.Metadata metadata)
ResponseMetadataHandleronHeaders in interface ResponseMetadataHandlerpublic void onTrailers(io.grpc.Metadata metadata)
ResponseMetadataHandleronTrailers in interface ResponseMetadataHandler