@Immutable
@CheckReturnValue
public final class CallOptions
extends java.lang.Object
A field that is not set is null
.
Modifier and Type | Class | Description |
---|---|---|
static class |
CallOptions.Key<T> |
Key for a key-value pair.
|
Modifier and Type | Field | Description |
---|---|---|
static CallOptions |
DEFAULT |
A blank
CallOptions that all fields are not set. |
Modifier and Type | Method | Description |
---|---|---|
java.lang.String |
getAuthority() |
Override the HTTP/2 authority the channel claims to be connecting to.
|
java.lang.String |
getCompressor() |
Returns the compressor's name.
|
CallCredentials |
getCredentials() |
Returns the call credentials.
|
io.grpc.Deadline |
getDeadline() |
Returns the deadline or
null if the deadline is not set. |
java.util.concurrent.Executor |
getExecutor() |
|
java.lang.Integer |
getMaxInboundMessageSize() |
Gets the maximum allowed message size acceptable from the remote peer.
|
java.lang.Integer |
getMaxOutboundMessageSize() |
Gets the maximum allowed message size acceptable to send the remote peer.
|
<T> T |
getOption(CallOptions.Key<T> key) |
Get the value for a custom option or its inherent default.
|
java.util.List<ClientStreamTracer.Factory> |
getStreamTracerFactories() |
Returns an immutable list of
ClientStreamTracerFactory s. |
boolean |
isWaitForReady() |
Returns whether
'wait for ready' option is enabled for the call.
|
java.lang.String |
toString() |
|
CallOptions |
withAuthority(java.lang.String authority) |
Override the HTTP/2 authority the channel claims to be connecting to.
|
CallOptions |
withCallCredentials(CallCredentials credentials) |
Returns a new
CallOptions with the given call credentials. |
CallOptions |
withCompression(java.lang.String compressorName) |
Sets the compression to use for the call.
|
CallOptions |
withDeadline(io.grpc.Deadline deadline) |
Returns a new
CallOptions with the given absolute deadline. |
CallOptions |
withDeadlineAfter(long duration,
java.util.concurrent.TimeUnit unit) |
Returns a new
CallOptions with a deadline that is after the given duration from
now. |
CallOptions |
withExecutor(java.util.concurrent.Executor executor) |
Returns a new
CallOptions with executor to be used instead of the default
executor specified with ManagedChannelBuilder.executor(java.util.concurrent.Executor) . |
CallOptions |
withMaxInboundMessageSize(int maxSize) |
Sets the maximum allowed message size acceptable from the remote peer.
|
CallOptions |
withMaxOutboundMessageSize(int maxSize) |
Sets the maximum allowed message size acceptable sent to the remote peer.
|
<T> CallOptions |
withOption(CallOptions.Key<T> key,
T value) |
Sets a custom option.
|
CallOptions |
withoutWaitForReady() |
Disables 'wait for ready' feature for the call.
|
CallOptions |
withStreamTracerFactory(ClientStreamTracer.Factory factory) |
Returns a new
CallOptions with a ClientStreamTracerFactory in addition to
the existing factories. |
CallOptions |
withWaitForReady() |
Enables
'wait for ready' feature for the call.
|
public static final CallOptions DEFAULT
CallOptions
that all fields are not set.@ExperimentalApi("https://github.com/grpc/grpc-java/issues/1767") public CallOptions withAuthority(@Nullable java.lang.String authority)
public CallOptions withCallCredentials(@Nullable CallCredentials credentials)
CallOptions
with the given call credentials.@ExperimentalApi("https://github.com/grpc/grpc-java/issues/1704") public CallOptions withCompression(@Nullable java.lang.String compressorName)
CompressorRegistry
.
It is only safe to call this if the server supports the compression format chosen. There is no negotiation performed; if the server does not support the compression chosen, the call will fail.
public CallOptions withDeadline(@Nullable io.grpc.Deadline deadline)
CallOptions
with the given absolute deadline.
This is mostly used for propagating an existing deadline. withDeadlineAfter(long, java.util.concurrent.TimeUnit)
is the
recommended way of setting a new deadline,
deadline
- the deadline or null
for unsetting the deadline.public CallOptions withDeadlineAfter(long duration, java.util.concurrent.TimeUnit unit)
CallOptions
with a deadline that is after the given duration
from
now.@Nullable public io.grpc.Deadline getDeadline()
null
if the deadline is not set.public CallOptions withWaitForReady()
public CallOptions withoutWaitForReady()
@ExperimentalApi("https://github.com/grpc/grpc-java/issues/1704") @Nullable public java.lang.String getCompressor()
@Nullable @ExperimentalApi("https://github.com/grpc/grpc-java/issues/1767") public java.lang.String getAuthority()
@Nullable public CallCredentials getCredentials()
public CallOptions withExecutor(@Nullable java.util.concurrent.Executor executor)
CallOptions
with executor
to be used instead of the default
executor specified with ManagedChannelBuilder.executor(java.util.concurrent.Executor)
.@ExperimentalApi("https://github.com/grpc/grpc-java/issues/2861") public CallOptions withStreamTracerFactory(ClientStreamTracer.Factory factory)
CallOptions
with a ClientStreamTracerFactory
in addition to
the existing factories.
This method doesn't replace existing factories, or try to de-duplicate factories.
@ExperimentalApi("https://github.com/grpc/grpc-java/issues/2861") public java.util.List<ClientStreamTracer.Factory> getStreamTracerFactories()
ClientStreamTracerFactory
s.public <T> CallOptions withOption(CallOptions.Key<T> key, T value)
key
- The option keyvalue
- The option value.@ExperimentalApi("https://github.com/grpc/grpc-java/issues/1869") public <T> T getOption(CallOptions.Key<T> key)
key
- Key identifying option@Nullable public java.util.concurrent.Executor getExecutor()
public boolean isWaitForReady()
@ExperimentalApi("https://github.com/grpc/grpc-java/issues/2563") public CallOptions withMaxInboundMessageSize(int maxSize)
ManagedChannelBuilder.maxInboundMessageSize(int)
.@ExperimentalApi("https://github.com/grpc/grpc-java/issues/2563") public CallOptions withMaxOutboundMessageSize(int maxSize)
@Nullable @ExperimentalApi("https://github.com/grpc/grpc-java/issues/2563") public java.lang.Integer getMaxInboundMessageSize()
@Nullable @ExperimentalApi("https://github.com/grpc/grpc-java/issues/2563") public java.lang.Integer getMaxOutboundMessageSize()
public java.lang.String toString()
toString
in class java.lang.Object