/** Returns a new instance with the channel set to the given channel. */ public GrpcCallContext withChannel(Channel newChannel) { return new GrpcCallContext( newChannel, this.callOptions, timeout, this.streamWaitTimeout, this.streamIdleTimeout, this.channelAffinity, this.extraHeaders); }
/** Returns a new instance with the call options set to the given call options. */ public GrpcCallContext withCallOptions(CallOptions newCallOptions) { return new GrpcCallContext( this.channel, newCallOptions, timeout, this.streamWaitTimeout, this.streamIdleTimeout, this.channelAffinity, this.extraHeaders); }
/** Returns a new instance with the channel set to the given channel. */ public GrpcCallContext withChannel(Channel newChannel) { return new GrpcCallContext( newChannel, this.callOptions, timeout, this.streamWaitTimeout, this.streamIdleTimeout, this.channelAffinity, this.extraHeaders); }
/** Returns a new instance with the call options set to the given call options. */ public GrpcCallContext withCallOptions(CallOptions newCallOptions) { return new GrpcCallContext( this.channel, newCallOptions, timeout, this.streamWaitTimeout, this.streamIdleTimeout, this.channelAffinity, this.extraHeaders); }
/** Returns an instance with the given channel and {@link CallOptions}. */ public static GrpcCallContext of(Channel channel, CallOptions callOptions) { return new GrpcCallContext( channel, callOptions, null, null, null, null, ImmutableMap.<String, List<String>>of()); }
/** Returns an empty instance with a null channel and default {@link CallOptions}. */ public static GrpcCallContext createDefault() { return new GrpcCallContext( null, CallOptions.DEFAULT, null, null, null, null, ImmutableMap.<String, List<String>>of()); }
/** Returns an empty instance with a null channel and default {@link CallOptions}. */ public static GrpcCallContext createDefault() { return new GrpcCallContext( null, CallOptions.DEFAULT, null, null, null, null, ImmutableMap.<String, List<String>>of()); }
/** Returns an instance with the given channel and {@link CallOptions}. */ public static GrpcCallContext of(Channel channel, CallOptions callOptions) { return new GrpcCallContext( channel, callOptions, null, null, null, null, ImmutableMap.<String, List<String>>of()); }
@BetaApi("The surface for channel affinity is not stable yet and may change in the future.") public GrpcCallContext withChannelAffinity(@Nullable Integer affinity) { return new GrpcCallContext( channel, callOptions, timeout, streamWaitTimeout, streamIdleTimeout, affinity, extraHeaders); }
@Override public GrpcCallContext withStreamWaitTimeout(@Nullable Duration streamWaitTimeout) { if (streamWaitTimeout != null) { Preconditions.checkArgument( streamWaitTimeout.compareTo(Duration.ZERO) >= 0, "Invalid timeout: < 0 s"); } return new GrpcCallContext( channel, callOptions, timeout, streamWaitTimeout, streamIdleTimeout, channelAffinity, extraHeaders); }
@BetaApi("The surface for channel affinity is not stable yet and may change in the future.") public GrpcCallContext withChannelAffinity(@Nullable Integer affinity) { return new GrpcCallContext( channel, callOptions, timeout, streamWaitTimeout, streamIdleTimeout, affinity, extraHeaders); }
@Override public GrpcCallContext withStreamIdleTimeout(@Nullable Duration streamIdleTimeout) { if (streamIdleTimeout != null) { Preconditions.checkArgument( streamIdleTimeout.compareTo(Duration.ZERO) >= 0, "Invalid timeout: < 0 s"); } return new GrpcCallContext( channel, callOptions, timeout, streamWaitTimeout, streamIdleTimeout, channelAffinity, extraHeaders); }
@Override public GrpcCallContext withStreamIdleTimeout(@Nullable Duration streamIdleTimeout) { if (streamIdleTimeout != null) { Preconditions.checkArgument( streamIdleTimeout.compareTo(Duration.ZERO) >= 0, "Invalid timeout: < 0 s"); } return new GrpcCallContext( channel, callOptions, timeout, streamWaitTimeout, streamIdleTimeout, channelAffinity, extraHeaders); }
@Override public GrpcCallContext withStreamWaitTimeout(@Nullable Duration streamWaitTimeout) { if (streamWaitTimeout != null) { Preconditions.checkArgument( streamWaitTimeout.compareTo(Duration.ZERO) >= 0, "Invalid timeout: < 0 s"); } return new GrpcCallContext( channel, callOptions, timeout, streamWaitTimeout, streamIdleTimeout, channelAffinity, extraHeaders); }
@BetaApi("The surface for extra headers is not stable yet and may change in the future.") @Override public GrpcCallContext withExtraHeaders(Map<String, List<String>> extraHeaders) { Preconditions.checkNotNull(extraHeaders); ImmutableMap<String, List<String>> newExtraHeaders = Headers.mergeHeaders(this.extraHeaders, extraHeaders); return new GrpcCallContext( channel, callOptions, timeout, streamWaitTimeout, streamIdleTimeout, channelAffinity, newExtraHeaders); }
@BetaApi("The surface for extra headers is not stable yet and may change in the future.") @Override public GrpcCallContext withExtraHeaders(Map<String, List<String>> extraHeaders) { Preconditions.checkNotNull(extraHeaders); ImmutableMap<String, List<String>> newExtraHeaders = Headers.mergeHeaders(this.extraHeaders, extraHeaders); return new GrpcCallContext( channel, callOptions, timeout, streamWaitTimeout, streamIdleTimeout, channelAffinity, newExtraHeaders); }
@Override public GrpcCallContext withTimeout(@Nullable Duration timeout) { // Default RetrySettings use 0 for RPC timeout. Treat that as disabled timeouts. if (timeout != null && (timeout.isZero() || timeout.isNegative())) { timeout = null; } // Prevent expanding timeouts if (timeout != null && this.timeout != null && this.timeout.compareTo(timeout) <= 0) { return this; } return new GrpcCallContext( this.channel, this.callOptions, timeout, this.streamWaitTimeout, this.streamIdleTimeout, this.channelAffinity, this.extraHeaders); }
@Override public GrpcCallContext withTimeout(@Nullable Duration timeout) { // Default RetrySettings use 0 for RPC timeout. Treat that as disabled timeouts. if (timeout != null && (timeout.isZero() || timeout.isNegative())) { timeout = null; } // Prevent expanding timeouts if (timeout != null && this.timeout != null && this.timeout.compareTo(timeout) <= 0) { return this; } return new GrpcCallContext( this.channel, this.callOptions, timeout, this.streamWaitTimeout, this.streamIdleTimeout, this.channelAffinity, this.extraHeaders); }
return new GrpcCallContext( newChannel, newCallOptions,
return new GrpcCallContext( newChannel, newCallOptions,