Class GrpcResponseMetadata (2.9.0)

  public 
  
 class 
 GrpcResponseMetadata 
  
 implements 
  
 ResponseMetadataHandler 
 

GrpcResponseMetadata provides a mechanism to access the headers and trailers returned by a gRPC client method.

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(); 

Inheritance

java.lang.Object > GrpcResponseMetadata

Constructors

  public 
  
 GrpcResponseMetadata 
 () 
 

Methods

  public 
  
 GrpcCallContext 
  
 addHandlers 
 ( 
 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.

Parameter
Name Description
apiCallContext ApiCallContext
Returns
Type Description
GrpcCallContext
  public 
  
 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.

Returns
Type Description
GrpcCallContext
  public 
  
 Metadata 
  
 getMetadata 
 () 
 

Returns the headers from the gRPC method as Metadata. If the call has not completed, will return null.

Returns
Type Description
io.grpc.Metadata
  public 
  
 Metadata 
  
 getTrailingMetadata 
 () 
 

Returns the trailers from the gRPC method as Metadata. If the call has not completed, will return null.

Returns
Type Description
io.grpc.Metadata
  public 
  
 void 
  
 onHeaders 
 ( 
 Metadata 
  
 metadata 
 ) 
 

Handle the headers returned by an RPC.

Parameter
Name Description
metadata io.grpc.Metadata
  public 
  
 void 
  
 onTrailers 
 ( 
 Metadata 
  
 metadata 
 ) 
 

Handle the trailers returned by an RPC.

Parameter
Name Description
metadata io.grpc.Metadata
Design a Mobile Site
View Site in Mobile | Classic
Share by: