Class GrpcCallContext

  • All Implemented Interfaces:
    com.google.api.gax.retrying.RetryingContext, com.google.api.gax.rpc.ApiCallContext

    @BetaApi("Reference ApiCallContext instead - this class is likely to experience breaking changes")
    public final class GrpcCallContext
    extends Object
    implements com.google.api.gax.rpc.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.

    • Method Detail

      • createDefault

        public static GrpcCallContext createDefault()
        Returns an empty instance with a null channel and default CallOptions.
      • of

        public static GrpcCallContext of​(io.grpc.Channel channel,
                                         io.grpc.CallOptions callOptions)
        Returns an instance with the given channel and CallOptions.
      • nullToSelf

        public GrpcCallContext nullToSelf​(com.google.api.gax.rpc.ApiCallContext inputContext)
        Returns inputContext cast to GrpcCallContext, or an empty GrpcCallContext if inputContext is null.
        Specified by:
        nullToSelf in interface com.google.api.gax.rpc.ApiCallContext
        Parameters:
        inputContext - the ApiCallContext to cast if it is not null
      • withCredentials

        public GrpcCallContext withCredentials​(com.google.auth.Credentials newCredentials)
        Specified by:
        withCredentials in interface com.google.api.gax.rpc.ApiCallContext
      • withTransportChannel

        public GrpcCallContext withTransportChannel​(com.google.api.gax.rpc.TransportChannel inputChannel)
        Specified by:
        withTransportChannel in interface com.google.api.gax.rpc.ApiCallContext
      • withTimeout

        public GrpcCallContext withTimeout​(@Nullable
                                           org.threeten.bp.Duration timeout)
        Specified by:
        withTimeout in interface com.google.api.gax.rpc.ApiCallContext
      • getTimeout

        @Nullable
        public org.threeten.bp.Duration getTimeout()
        Specified by:
        getTimeout in interface com.google.api.gax.rpc.ApiCallContext
      • withStreamWaitTimeout

        public GrpcCallContext withStreamWaitTimeout​(@Nullable
                                                     org.threeten.bp.Duration streamWaitTimeout)
        Specified by:
        withStreamWaitTimeout in interface com.google.api.gax.rpc.ApiCallContext
      • withStreamIdleTimeout

        public GrpcCallContext withStreamIdleTimeout​(@Nullable
                                                     org.threeten.bp.Duration streamIdleTimeout)
        Specified by:
        withStreamIdleTimeout in interface com.google.api.gax.rpc.ApiCallContext
      • 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:
        withExtraHeaders in interface com.google.api.gax.rpc.ApiCallContext
      • getRetrySettings

        public com.google.api.gax.retrying.RetrySettings getRetrySettings()
        Specified by:
        getRetrySettings in interface com.google.api.gax.retrying.RetryingContext
      • withRetrySettings

        public GrpcCallContext withRetrySettings​(com.google.api.gax.retrying.RetrySettings retrySettings)
        Specified by:
        withRetrySettings in interface com.google.api.gax.rpc.ApiCallContext
      • getRetryableCodes

        public Set<com.google.api.gax.rpc.StatusCode.Code> getRetryableCodes()
        Specified by:
        getRetryableCodes in interface com.google.api.gax.retrying.RetryingContext
      • withRetryableCodes

        public GrpcCallContext withRetryableCodes​(Set<com.google.api.gax.rpc.StatusCode.Code> retryableCodes)
        Specified by:
        withRetryableCodes in interface com.google.api.gax.rpc.ApiCallContext
      • merge

        public com.google.api.gax.rpc.ApiCallContext merge​(com.google.api.gax.rpc.ApiCallContext inputCallContext)
        Specified by:
        merge in interface com.google.api.gax.rpc.ApiCallContext
      • getChannel

        public io.grpc.Channel getChannel()
        The Channel set on this context.
      • getCallOptions

        public io.grpc.CallOptions getCallOptions()
        The CallOptions set on this context.
      • getStreamWaitTimeout

        @Nullable
        public org.threeten.bp.Duration getStreamWaitTimeout()
        The stream wait timeout set for this context.
        Specified by:
        getStreamWaitTimeout in interface com.google.api.gax.rpc.ApiCallContext
        See Also:
        ApiCallContext.withStreamWaitTimeout(Duration)
      • getStreamIdleTimeout

        @Nullable
        public org.threeten.bp.Duration getStreamIdleTimeout()
        The stream idle timeout set for this context.
        Specified by:
        getStreamIdleTimeout in interface com.google.api.gax.rpc.ApiCallContext
        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:
        getExtraHeaders in interface com.google.api.gax.rpc.ApiCallContext
      • 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 com.google.api.gax.tracing.ApiTracer getTracer()
        Specified by:
        getTracer in interface com.google.api.gax.rpc.ApiCallContext
        Specified by:
        getTracer in interface com.google.api.gax.retrying.RetryingContext
      • withTracer

        public GrpcCallContext withTracer​(@Nonnull
                                          com.google.api.gax.tracing.ApiTracer tracer)
        Specified by:
        withTracer in interface com.google.api.gax.rpc.ApiCallContext
      • withOption

        public <T> GrpcCallContext withOption​(com.google.api.gax.rpc.ApiCallContext.Key<T> key,
                                              T value)
        Specified by:
        withOption in interface com.google.api.gax.rpc.ApiCallContext
      • getOption

        public <T> T getOption​(com.google.api.gax.rpc.ApiCallContext.Key<T> key)
        Specified by:
        getOption in interface com.google.api.gax.rpc.ApiCallContext
      • hashCode

        public int hashCode()
        Overrides:
        hashCode in class Object