@Immutable @CheckReturnValue public final class CallOptions extends Object
A field that is not set is null
.
Modifier and Type | Class and Description |
---|---|
static class |
CallOptions.Key<T>
Key for a key-value pair.
|
Modifier and Type | Field and Description |
---|---|
static CallOptions |
DEFAULT
A blank
CallOptions that all fields are not set. |
Modifier and Type | Method and Description |
---|---|
String |
getAuthority()
Override the HTTP/2 authority the channel claims to be connecting to.
|
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. |
Executor |
getExecutor() |
Integer |
getMaxInboundMessageSize()
Gets the maximum allowed message size acceptable from the remote peer.
|
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.
|
List<ClientStreamTracer.Factory> |
getStreamTracerFactories()
Returns an immutable list of
ClientStreamTracerFactory s. |
boolean |
isWaitForReady()
Returns whether
'wait for ready' option is enabled for the call.
|
String |
toString() |
CallOptions |
withAuthority(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(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,
TimeUnit unit)
Returns a new
CallOptions with a deadline that is after the given duration from
now. |
CallOptions |
withExecutor(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(value="https://github.com/grpc/grpc-java/issues/1767") public CallOptions withAuthority(@Nullable String authority)
public CallOptions withCallCredentials(@Nullable CallCredentials credentials)
CallOptions
with the given call credentials.@ExperimentalApi(value="https://github.com/grpc/grpc-java/issues/1704") public CallOptions withCompression(@Nullable 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, 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(value="https://github.com/grpc/grpc-java/issues/1704") @Nullable public String getCompressor()
@Nullable @ExperimentalApi(value="https://github.com/grpc/grpc-java/issues/1767") public String getAuthority()
@Nullable public CallCredentials getCredentials()
public CallOptions withExecutor(@Nullable Executor executor)
CallOptions
with executor
to be used instead of the default
executor specified with ManagedChannelBuilder.executor(java.util.concurrent.Executor)
.@ExperimentalApi(value="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(value="https://github.com/grpc/grpc-java/issues/2861") public List<ClientStreamTracer.Factory> getStreamTracerFactories()
ClientStreamTracerFactory
s.public <T> CallOptions withOption(CallOptions.Key<T> key, T value)
key
- The option keyvalue
- The option value.@ExperimentalApi(value="https://github.com/grpc/grpc-java/issues/1869") public <T> T getOption(CallOptions.Key<T> key)
key
- Key identifying optionpublic boolean isWaitForReady()
@ExperimentalApi(value="https://github.com/grpc/grpc-java/issues/2563") public CallOptions withMaxInboundMessageSize(int maxSize)
ManagedChannelBuilder.maxInboundMessageSize(int)
.@ExperimentalApi(value="https://github.com/grpc/grpc-java/issues/2563") public CallOptions withMaxOutboundMessageSize(int maxSize)
@Nullable @ExperimentalApi(value="https://github.com/grpc/grpc-java/issues/2563") public Integer getMaxInboundMessageSize()
@Nullable @ExperimentalApi(value="https://github.com/grpc/grpc-java/issues/2563") public Integer getMaxOutboundMessageSize()