mirror of https://github.com/grpc/grpc-java.git
cronet: add getter for retrieving grpc cronet annotations in calloptions. (#6086)
This commit is contained in:
parent
63661c7b70
commit
be226aa99c
|
|
@ -18,6 +18,8 @@ package io.grpc.cronet;
|
|||
|
||||
import io.grpc.CallOptions;
|
||||
import io.grpc.Internal;
|
||||
import java.util.Collection;
|
||||
import java.util.Collections;
|
||||
|
||||
/**
|
||||
* Internal accessor class for call options using with the Cronet transport. This is intended for
|
||||
|
|
@ -33,4 +35,17 @@ public final class InternalCronetCallOptions {
|
|||
public static CallOptions withAnnotation(CallOptions callOptions, Object annotation) {
|
||||
return CronetClientStream.withAnnotation(callOptions, annotation);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns Cronet annotations for gRPC included in the given {@code callOptions}. Annotations
|
||||
* are attached via {@link #withAnnotation(CallOptions, Object)}.
|
||||
*/
|
||||
public static Collection<Object> getAnnotations(CallOptions callOptions) {
|
||||
Collection<Object> annotations =
|
||||
callOptions.getOption(CronetClientStream.CRONET_ANNOTATIONS_KEY);
|
||||
if (annotations == null) {
|
||||
annotations = Collections.emptyList();
|
||||
}
|
||||
return annotations;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue