S - the concrete type of this stub.public abstract class AbstractStub<S extends AbstractStub<S>> extends Object
This is the base class of the stub classes from the generated code. It allows for reconfiguration, e.g., attaching interceptors to the stub.
| Modifier | Constructor and Description |
|---|---|
protected |
AbstractStub(io.grpc.Channel channel)
Constructor for use by subclasses, with the default
CallOptions. |
protected |
AbstractStub(io.grpc.Channel channel,
io.grpc.CallOptions callOptions)
Constructor for use by subclasses, with the default
CallOptions. |
| Modifier and Type | Method and Description |
|---|---|
protected abstract S |
build(io.grpc.Channel channel,
io.grpc.CallOptions callOptions)
Returns a new stub with the given channel for the provided method configurations.
|
io.grpc.CallOptions |
getCallOptions()
The
CallOptions of the stub. |
io.grpc.Channel |
getChannel()
The underlying channel of the stub.
|
S |
withChannel(io.grpc.Channel newChannel)
Returns a new stub that uses the given channel.
|
S |
withDeadlineAfter(long duration,
TimeUnit unit)
Returns a new stub with a deadline that is after the given
duration from now. |
S |
withDeadlineNanoTime(Long deadlineNanoTime)
Returns a new stub with an absolute deadline in nanoseconds in the clock as per
System.nanoTime(). |
S |
withInterceptors(io.grpc.ClientInterceptor... interceptors)
Returns a new stub that has the given interceptors attached to the underlying channel.
|
protected AbstractStub(io.grpc.Channel channel)
CallOptions.channel - the channel that this stub will use to do communicationsprotected AbstractStub(io.grpc.Channel channel,
io.grpc.CallOptions callOptions)
CallOptions.channel - the channel that this stub will use to do communicationscallOptions - the runtime call options to be applied to every call on this stubpublic final io.grpc.Channel getChannel()
public final io.grpc.CallOptions getCallOptions()
CallOptions of the stub.protected abstract S build(io.grpc.Channel channel, io.grpc.CallOptions callOptions)
channel - the channel that this stub will use to do communicationscallOptions - the runtime call options to be applied to every call on this stubpublic final S withDeadlineNanoTime(@Nullable Long deadlineNanoTime)
System.nanoTime().
This is mostly used for propagating an existing deadline. withDeadlineAfter(long, java.util.concurrent.TimeUnit) is the
recommended way of setting a new deadline,
deadlineNanoTime - nanoseconds in the clock as per System.nanoTime()public final S withDeadlineAfter(long duration, TimeUnit unit)
duration from now.CallOptions.withDeadlineAfter(long, java.util.concurrent.TimeUnit)public final S withChannel(io.grpc.Channel newChannel)
public final S withInterceptors(io.grpc.ClientInterceptor... interceptors)