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 as withTransportChannel(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> -
Field Summary
Fields -
Method Summary
Modifier and TypeMethodDescriptionstatic GrpcCallContextReturns an empty instance with a null channel and defaultCallOptions.booleanio.grpc.CallOptionsTheCallOptionsset on this context.io.grpc.ChannelTheChannelset on this context.The channel affinity for this context.The extra header for this context.<T> TgetOption(ApiCallContext.Key<T> key) org.threeten.bp.DurationThis method is obsolete.The stream idle timeout set for this context.org.threeten.bp.DurationThis method is obsolete.The stream wait timeout set for this context.org.threeten.bp.DurationThis method is obsolete.inthashCode()merge(ApiCallContext inputCallContext) nullToSelf(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.voidValidate the Universe Domain to ensure that the user configured Universe Domain and the Credentials' Universe Domain match.withCallOptions(io.grpc.CallOptions newCallOptions) Returns a new instance with the call options set to the given call options.withChannel(io.grpc.Channel newChannel) Returns a new instance with the channel set to the given channel.withChannelAffinity(Integer affinity) withCredentials(com.google.auth.Credentials newCredentials) withEndpointContext(EndpointContext endpointContext) withExtraHeaders(Map<String, List<String>> extraHeaders) <T> GrpcCallContextwithOption(ApiCallContext.Key<T> key, T value) withRequestParamsDynamicHeaderOption(String requestParams) withRetryableCodes(Set<StatusCode.Code> retryableCodes) withRetrySettings(RetrySettings retrySettings) withStreamIdleTimeout(org.threeten.bp.Duration streamIdleTimeout) This method is obsolete.withStreamIdleTimeoutDuration(Duration streamIdleTimeout) withStreamWaitTimeout(org.threeten.bp.Duration streamWaitTimeout) This method is obsolete.withStreamWaitTimeoutDuration(Duration streamWaitTimeout) withTimeout(org.threeten.bp.Duration timeout) This method is obsolete.withTimeoutDuration(Duration timeout) withTracer(ApiTracer tracer) withTransportChannel(TransportChannel inputChannel)
-
Field Details
-
TRACER_KEY
-
-
Method Details
-
createDefault
Returns an empty instance with a null channel and defaultCallOptions. -
of
Returns an instance with the given channel andCallOptions. -
nullToSelf
Returns inputContext cast toGrpcCallContext, or an emptyGrpcCallContextif inputContext is null.- Specified by:
nullToSelfin interfaceApiCallContext- Parameters:
inputContext- theApiCallContextto cast if it is not null
-
withCredentials
- Specified by:
withCredentialsin interfaceApiCallContext
-
withTransportChannel
- Specified by:
withTransportChannelin interfaceApiCallContext
-
withEndpointContext
- Specified by:
withEndpointContextin interfaceApiCallContext
-
withTimeout
@ObsoleteApi("Use withTimeoutDuration(java.time.Duration) instead") public GrpcCallContext withTimeout(@Nullable org.threeten.bp.Duration timeout) This method is obsolete. UsewithTimeoutDuration(java.time.Duration)instead.- Specified by:
withTimeoutin interfaceApiCallContext
-
withTimeoutDuration
- Specified by:
withTimeoutDurationin interfaceApiCallContext
-
getTimeout
@Nullable @ObsoleteApi("Use getTimeoutDuration() instead") public org.threeten.bp.Duration getTimeout()This method is obsolete. UsegetTimeoutDuration()instead.- Specified by:
getTimeoutin interfaceApiCallContext
-
getTimeoutDuration
- Specified by:
getTimeoutDurationin interfaceApiCallContext
-
withStreamWaitTimeout
@ObsoleteApi("Use withStreamWaitTimeoutDuration(java.time.Duration) instead") public GrpcCallContext withStreamWaitTimeout(@Nullable org.threeten.bp.Duration streamWaitTimeout) This method is obsolete. UsewithStreamWaitTimeoutDuration(java.time.Duration)instead.- Specified by:
withStreamWaitTimeoutin interfaceApiCallContext
-
withStreamWaitTimeoutDuration
- Specified by:
withStreamWaitTimeoutDurationin interfaceApiCallContext
-
withStreamIdleTimeout
@ObsoleteApi("Use withStreamIdleTimeoutDuration(java.time.Duration) instead") public GrpcCallContext withStreamIdleTimeout(@Nullable org.threeten.bp.Duration streamIdleTimeout) This method is obsolete. UsewithStreamIdleTimeoutDuration(java.time.Duration)instead.- Specified by:
withStreamIdleTimeoutin interfaceApiCallContext
-
withStreamIdleTimeoutDuration
- Specified by:
withStreamIdleTimeoutDurationin 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
- Specified by:
getRetrySettingsin interfaceRetryingContext
-
withRetrySettings
- Specified by:
withRetrySettingsin interfaceApiCallContext
-
getRetryableCodes
- Specified by:
getRetryableCodesin interfaceRetryingContext
-
withRetryableCodes
- Specified by:
withRetryableCodesin interfaceApiCallContext
-
merge
- 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 @ObsoleteApi("Use getStreamWaitTimeoutDuration() instead") public org.threeten.bp.Duration getStreamWaitTimeout()This method is obsolete. UsegetStreamWaitTimeoutDuration()instead.- Specified by:
getStreamWaitTimeoutin interfaceApiCallContext
-
getStreamWaitTimeoutDuration
The stream wait timeout set for this context.- Specified by:
getStreamWaitTimeoutDurationin interfaceApiCallContext- See Also:
-
getStreamIdleTimeout
@Nullable @ObsoleteApi("Use getStreamIdleTimeoutDuration() instead") public org.threeten.bp.Duration getStreamIdleTimeout()This method is obsolete. UsegetStreamIdleTimeoutDuration()instead.- Specified by:
getStreamIdleTimeoutin interfaceApiCallContext
-
getStreamIdleTimeoutDuration
The stream idle timeout set for this context.- Specified by:
getStreamIdleTimeoutDurationin interfaceApiCallContext- See Also:
-
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
Returns a new instance with the channel set to the given channel. -
withCallOptions
Returns a new instance with the call options set to the given call options. -
withRequestParamsDynamicHeaderOption
-
getTracer
- Specified by:
getTracerin interfaceApiCallContext- Specified by:
getTracerin interfaceRetryingContext
-
withTracer
- Specified by:
withTracerin interfaceApiCallContext
-
withOption
- Specified by:
withOptionin interfaceApiCallContext
-
getOption
- Specified by:
getOptionin interfaceApiCallContext
-
validateUniverseDomain
Validate the Universe Domain to ensure that the user configured Universe Domain and the Credentials' Universe Domain match. An exception will be raised if there are any issues when trying to validate (i.e. unable to access the universe domain).- Throws:
UnauthenticatedException- Thrown if the universe domain that the user configured does not match the Credential's universe domain.UnavailableException- If client library is unable to retrieve the universe domain from the Credentials and the RPC is configured to retry Unavailable exceptions, the client library will attempt to retry with the RPC's defined retry bounds. If the retry bounds have been exceeded and the library is still unable to retrieve the universe domain, the exception will be thrown back to the user.
-
hashCode
public int hashCode() -
equals
-