@Immutable 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> |
| Modifier and Type | Field and Description |
|---|---|
static CallOptions |
DEFAULT
A blank
CallOptions that all fields are not set. |
| Modifier and Type | Method and Description |
|---|---|
Attributes |
getAffinity()
Returns the attributes for affinity-based routing.
|
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.
|
Deadline |
getDeadline()
Returns the deadline or
null if the deadline is not set. |
Long |
getDeadlineNanoTime()
Deprecated.
Use
getDeadline() instead. |
Executor |
getExecutor() |
<T> T |
getOption(CallOptions.Key<T> key)
Get the value for a custom option or its inherent default.
|
boolean |
isWaitForReady()
Returns whether 'wait for ready' option is enabled for the call.
|
String |
toString() |
CallOptions |
withAffinity(Attributes affinity)
Returns a new
CallOptions with attributes for affinity-based routing. |
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(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 |
withDeadlineNanoTime(Long deadlineNanoTime)
Deprecated.
Use
withDeadline(Deadline) instead. |
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). |
<T> CallOptions |
withOption(CallOptions.Key<T> key,
T value)
Sets a custom option.
|
CallOptions |
withoutWaitForReady()
Disables 'wait for ready' feature for the call.
|
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)
@ExperimentalApi(value="https//github.com/grpc/grpc-java/issues/1914") 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.public CallOptions withDeadline(@Nullable 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.@Deprecated public CallOptions withDeadlineNanoTime(@Nullable Long deadlineNanoTime)
withDeadline(Deadline) instead.CallOptions with the given absolute deadline in nanoseconds in the clock
as per 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 - the deadline in the clock as per System.nanoTime().
null for unsetting the deadline.public CallOptions withDeadlineAfter(long duration, TimeUnit unit)
CallOptions with a deadline that is after the given duration from
now.@Deprecated public Long getDeadlineNanoTime()
getDeadline() instead.System.nanoTime(). null
if the deadline is not set.@Nullable public Deadline getDeadline()
null if the deadline is not set.@ExperimentalApi(value="https://github.com/grpc/grpc-java/issues/1766") public CallOptions withAffinity(Attributes affinity)
CallOptions with attributes for affinity-based routing.@ExperimentalApi(value="https://github.com/grpc/grpc-java/issues/1915") public CallOptions withWaitForReady()
@ExperimentalApi(value="https://github.com/grpc/grpc-java/issues/1915") public CallOptions withoutWaitForReady()
@ExperimentalApi(value="https://github.com/grpc/grpc-java/issues/1766") public Attributes getAffinity()
@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()
@ExperimentalApi(value="https//github.com/grpc/grpc-java/issues/1914") @Nullable public CallCredentials getCredentials()
public CallOptions withExecutor(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/1869") 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 option@ExperimentalApi(value="https://github.com/grpc/grpc-java/issues/1915") public boolean isWaitForReady()