Package com.google.api.gax.grpc
Class GrpcCallContext
- java.lang.Object
-
- com.google.api.gax.grpc.GrpcCallContext
-
- All Implemented Interfaces:
RetryingContext,ApiCallContext
@BetaApi("Reference ApiCallContext instead - this class is likely to experience breaking changes") public final class GrpcCallContext extends Object implements ApiCallContext
GrpcCallContext encapsulates context data used to make a grpc call.GrpcCallContext is immutable in the sense that none of its methods modifies the GrpcCallContext itself or the underlying data. Methods of the form
withX, such aswithTransportChannel(com.google.api.gax.rpc.TransportChannel), return copies of the object, but with one field changed. The immutability and thread safety of the arguments solely depends on the arguments themselves.
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from interface com.google.api.gax.rpc.ApiCallContext
ApiCallContext.Key<T extends Object>
-
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description static GrpcCallContextcreateDefault()Returns an empty instance with a null channel and defaultCallOptions.booleanequals(Object o)io.grpc.CallOptionsgetCallOptions()TheCallOptionsset on this context.io.grpc.ChannelgetChannel()TheChannelset on this context.IntegergetChannelAffinity()The channel affinity for this context.Map<String,List<String>>getExtraHeaders()The extra header for this context.<T> TgetOption(ApiCallContext.Key<T> key)Set<StatusCode.Code>getRetryableCodes()RetrySettingsgetRetrySettings()org.threeten.bp.DurationgetStreamIdleTimeout()The stream idle timeout set for this context.org.threeten.bp.DurationgetStreamWaitTimeout()The stream wait timeout set for this context.org.threeten.bp.DurationgetTimeout()ApiTracergetTracer()inthashCode()ApiCallContextmerge(ApiCallContext inputCallContext)GrpcCallContextnullToSelf(ApiCallContext inputContext)Returns inputContext cast toGrpcCallContext, or an emptyGrpcCallContextif inputContext is null.static GrpcCallContextof(io.grpc.Channel channel, io.grpc.CallOptions callOptions)Returns an instance with the given channel andCallOptions.GrpcCallContextwithCallOptions(io.grpc.CallOptions newCallOptions)Returns a new instance with the call options set to the given call options.GrpcCallContextwithChannel(io.grpc.Channel newChannel)Returns a new instance with the channel set to the given channel.GrpcCallContextwithChannelAffinity(Integer affinity)GrpcCallContextwithCredentials(com.google.auth.Credentials newCredentials)GrpcCallContextwithExtraHeaders(Map<String,List<String>> extraHeaders)<T> GrpcCallContextwithOption(ApiCallContext.Key<T> key, T value)GrpcCallContextwithRequestParamsDynamicHeaderOption(String requestParams)GrpcCallContextwithRetryableCodes(Set<StatusCode.Code> retryableCodes)GrpcCallContextwithRetrySettings(RetrySettings retrySettings)GrpcCallContextwithStreamIdleTimeout(org.threeten.bp.Duration streamIdleTimeout)GrpcCallContextwithStreamWaitTimeout(org.threeten.bp.Duration streamWaitTimeout)GrpcCallContextwithTimeout(org.threeten.bp.Duration timeout)GrpcCallContextwithTracer(ApiTracer tracer)GrpcCallContextwithTransportChannel(TransportChannel inputChannel)
-
-
-
Method Detail
-
createDefault
public static GrpcCallContext createDefault()
Returns an empty instance with a null channel and defaultCallOptions.
-
of
public static GrpcCallContext of(io.grpc.Channel channel, io.grpc.CallOptions callOptions)
Returns an instance with the given channel andCallOptions.
-
nullToSelf
public GrpcCallContext nullToSelf(ApiCallContext inputContext)
Returns inputContext cast toGrpcCallContext, or an emptyGrpcCallContextif inputContext is null.- Specified by:
nullToSelfin interfaceApiCallContext- Parameters:
inputContext- theApiCallContextto cast if it is not null
-
withCredentials
public GrpcCallContext withCredentials(com.google.auth.Credentials newCredentials)
- Specified by:
withCredentialsin interfaceApiCallContext
-
withTransportChannel
public GrpcCallContext withTransportChannel(TransportChannel inputChannel)
- Specified by:
withTransportChannelin interfaceApiCallContext
-
withTimeout
public GrpcCallContext withTimeout(@Nullable org.threeten.bp.Duration timeout)
- Specified by:
withTimeoutin interfaceApiCallContext
-
getTimeout
@Nullable public org.threeten.bp.Duration getTimeout()
- Specified by:
getTimeoutin interfaceApiCallContext
-
withStreamWaitTimeout
public GrpcCallContext withStreamWaitTimeout(@Nullable org.threeten.bp.Duration streamWaitTimeout)
- Specified by:
withStreamWaitTimeoutin interfaceApiCallContext
-
withStreamIdleTimeout
public GrpcCallContext withStreamIdleTimeout(@Nullable org.threeten.bp.Duration streamIdleTimeout)
- Specified by:
withStreamIdleTimeoutin interfaceApiCallContext
-
withChannelAffinity
@BetaApi("The surface for channel affinity is not stable yet and may change in the future.") public GrpcCallContext withChannelAffinity(@Nullable Integer affinity)
-
withExtraHeaders
@BetaApi("The surface for extra headers is not stable yet and may change in the future.") public GrpcCallContext withExtraHeaders(Map<String,List<String>> extraHeaders)
- Specified by:
withExtraHeadersin interfaceApiCallContext
-
getRetrySettings
public RetrySettings getRetrySettings()
- Specified by:
getRetrySettingsin interfaceRetryingContext
-
withRetrySettings
public GrpcCallContext withRetrySettings(RetrySettings retrySettings)
- Specified by:
withRetrySettingsin interfaceApiCallContext
-
getRetryableCodes
public Set<StatusCode.Code> getRetryableCodes()
- Specified by:
getRetryableCodesin interfaceRetryingContext
-
withRetryableCodes
public GrpcCallContext withRetryableCodes(Set<StatusCode.Code> retryableCodes)
- Specified by:
withRetryableCodesin interfaceApiCallContext
-
merge
public ApiCallContext merge(ApiCallContext inputCallContext)
- Specified by:
mergein interfaceApiCallContext
-
getChannel
public io.grpc.Channel getChannel()
TheChannelset on this context.
-
getCallOptions
public io.grpc.CallOptions getCallOptions()
TheCallOptionsset on this context.
-
getStreamWaitTimeout
@Nullable public org.threeten.bp.Duration getStreamWaitTimeout()
The stream wait timeout set for this context.- Specified by:
getStreamWaitTimeoutin interfaceApiCallContext- See Also:
ApiCallContext.withStreamWaitTimeout(Duration)
-
getStreamIdleTimeout
@Nullable public org.threeten.bp.Duration getStreamIdleTimeout()
The stream idle timeout set for this context.- Specified by:
getStreamIdleTimeoutin interfaceApiCallContext- See Also:
ApiCallContext.withStreamIdleTimeout(Duration)
-
getChannelAffinity
@Nullable public Integer getChannelAffinity()
The channel affinity for this context.
-
getExtraHeaders
@BetaApi("The surface for extra headers is not stable yet and may change in the future.") public Map<String,List<String>> getExtraHeaders()
The extra header for this context.- Specified by:
getExtraHeadersin interfaceApiCallContext
-
withChannel
public GrpcCallContext withChannel(io.grpc.Channel newChannel)
Returns a new instance with the channel set to the given channel.
-
withCallOptions
public GrpcCallContext withCallOptions(io.grpc.CallOptions newCallOptions)
Returns a new instance with the call options set to the given call options.
-
withRequestParamsDynamicHeaderOption
public GrpcCallContext withRequestParamsDynamicHeaderOption(String requestParams)
-
getTracer
@Nonnull public ApiTracer getTracer()
- Specified by:
getTracerin interfaceApiCallContext- Specified by:
getTracerin interfaceRetryingContext
-
withTracer
public GrpcCallContext withTracer(@Nonnull ApiTracer tracer)
- Specified by:
withTracerin interfaceApiCallContext
-
withOption
public <T> GrpcCallContext withOption(ApiCallContext.Key<T> key, T value)
- Specified by:
withOptionin interfaceApiCallContext
-
getOption
public <T> T getOption(ApiCallContext.Key<T> key)
- Specified by:
getOptionin interfaceApiCallContext
-
-