Skip to content

Commit

Permalink
cronet: add getter for retrieving grpc cronet annotations in callopti…
Browse files Browse the repository at this point in the history
…ons. (grpc#6086)
  • Loading branch information
voidzcy authored Aug 21, 2019
1 parent 63661c7 commit be226aa
Showing 1 changed file with 15 additions and 0 deletions.
15 changes: 15 additions & 0 deletions cronet/src/main/java/io/grpc/cronet/InternalCronetCallOptions.java
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@

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
Expand All @@ -33,4 +35,17 @@ private 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;
}
}

0 comments on commit be226aa

Please sign in to comment.