Top Description Inners Fields Constructors Methods
io.grpc

public final Class CallOptions

extends Object
Class Inheritance
Annotations
@Immutable
@CheckReturnValue
Static Imports
com.google.common.base.Preconditions.checkArgument

The collection of runtime options for a new RPC call.

A field that is not set is null.

Nested and Inner Type Summary

Modifier and TypeClass and Description
pack-priv static class
public static class
CallOptions.Key<T>

Key for a key-value pair.

Field Summary

Modifier and TypeField and Description
private final String
private final String
private final CallCredentials
private final Object[][]
private final Deadline
public static final CallOptions
DEFAULT

A blank CallOptions that all fields are not set.

private final Executor
private final Integer
private final Integer
private final List<ClientStreamTracer.Factory>
private final Boolean
waitForReady

Opposite to fail fast.

Constructor Summary

AccessConstructor and Description
private

Method Summary

Modifier and TypeMethod and Description
public String
getAuthority()

Override the HTTP/2 authority the channel claims to be connecting to.

public String
getCompressor()

Returns the compressor's name.

public CallCredentials
getCredentials()

Returns the call credentials.

public Deadline
getDeadline()

Returns the deadline or null if the deadline is not set.

public Executor
getExecutor()

Returns the executor override to use for this specific call, or null if there is no override.

public Integer
getMaxInboundMessageSize()

Gets the maximum allowed message size acceptable from the remote peer.

public Integer
getMaxOutboundMessageSize()

Gets the maximum allowed message size acceptable to send the remote peer.

public <T> T
getOption(CallOptions.Key<T>
Key identifying option
key
)

Get the value for a custom option or its inherent default.

public List<ClientStreamTracer.Factory>
getStreamTracerFactories()

Returns an immutable list of ClientStreamTracerFactorys.

pack-priv Boolean
public boolean
isWaitForReady()

Returns whether 'wait for ready' option is enabled for the call.

private static CallOptions.Builder
toBuilder(CallOptions other)

Copy CallOptions.

public String
toString()

Overrides java.lang.Object.toString.

Returns a string representation of the object.
public CallOptions
withAuthority(String authority)

Override the HTTP/2 authority the channel claims to be connecting to.

public CallOptions
withCallCredentials(CallCredentials credentials)

Returns a new CallOptions with the given call credentials.

public CallOptions
withCompression(String compressorName)

Sets the compression to use for the call.

public CallOptions
withDeadline(Deadline
the deadline or null for unsetting the deadline.
deadline
)

Returns a new CallOptions with the given absolute deadline.

public CallOptions
withDeadlineAfter(long duration, TimeUnit unit)

Returns a new CallOptions with a deadline that is after the given duration from now.

public CallOptions
withExecutor(Executor executor)

Returns a new CallOptions with executor to be used instead of the default executor specified with ManagedChannelBuilder#executor.

public CallOptions
withMaxInboundMessageSize(int maxSize)

Sets the maximum allowed message size acceptable from the remote peer.

public CallOptions
withMaxOutboundMessageSize(int maxSize)

Sets the maximum allowed message size acceptable sent to the remote peer.

public <T> CallOptions
withOption(CallOptions.Key<T>
The option key
key
,
T
The option value.
value
)

Sets a custom option.

public CallOptions
withoutWaitForReady()

Disables 'wait for ready' feature for the call.

public CallOptions
withStreamTracerFactory(ClientStreamTracer.Factory factory)

Returns a new CallOptions with a ClientStreamTracerFactory in addition to the existing factories.

public CallOptions
withWaitForReady()

Enables 'wait for ready' for the call.

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAllwaitwaitwait

Field Detail

authorityback to summary
private final String authority
Annotations
@Nullable
compressorNameback to summary
private final String compressorName
Annotations
@Nullable
credentialsback to summary
private final CallCredentials credentials
Annotations
@Nullable
customOptionsback to summary
private final Object[][] customOptions
deadlineback to summary
private final Deadline deadline
Annotations
@Nullable
DEFAULTback to summary
public static final CallOptions DEFAULT

A blank CallOptions that all fields are not set.

executorback to summary
private final Executor executor
Annotations
@Nullable
maxInboundMessageSizeback to summary
private final Integer maxInboundMessageSize
Annotations
@Nullable
maxOutboundMessageSizeback to summary
private final Integer maxOutboundMessageSize
Annotations
@Nullable
streamTracerFactoriesback to summary
private final List<ClientStreamTracer.Factory> streamTracerFactories
waitForReadyback to summary
private final Boolean waitForReady

Opposite to fail fast.

Annotations
@Nullable

Constructor Detail

CallOptionsback to summary
private CallOptions(CallOptions.Builder builder)

Method Detail

getAuthorityback to summary
public String getAuthority()

Override the HTTP/2 authority the channel claims to be connecting to. This is not generally safe. Overriding allows advanced users to re-use a single Channel for multiple services, even if those services are hosted on different domain names. That assumes the server is virtually hosting multiple domains and is guaranteed to continue doing so. It is rare for a service provider to make such a guarantee. At this time, there is no security verification of the overridden value, such as making sure the authority matches the server's TLS certificate.

Annotations
@Nullable
@ExperimentalApi:https://github.com/grpc/grpc-java/issues/1767
getCompressorback to summary
public String getCompressor()

Returns the compressor's name.

Annotations
@Nullable
getCredentialsback to summary
public CallCredentials getCredentials()

Returns the call credentials.

Annotations
@Nullable
getDeadlineback to summary
public Deadline getDeadline()

Returns the deadline or null if the deadline is not set.

Annotations
@Nullable
getExecutorback to summary
public Executor getExecutor()

Returns the executor override to use for this specific call, or null if there is no override. The executor is only for servicing this one call, so is not safe to use after ClientCall.Listener#onClose.

Annotations
@Nullable
getMaxInboundMessageSizeback to summary
public Integer getMaxInboundMessageSize()

Gets the maximum allowed message size acceptable from the remote peer.

Annotations
@Nullable
@ExperimentalApi:https://github.com/grpc/grpc-java/issues/2563
getMaxOutboundMessageSizeback to summary
public Integer getMaxOutboundMessageSize()

Gets the maximum allowed message size acceptable to send the remote peer.

Annotations
@Nullable
@ExperimentalApi:https://github.com/grpc/grpc-java/issues/2563
getOptionback to summary
public <T> T getOption(CallOptions.Key<T> key)

Get the value for a custom option or its inherent default.

Parameters
key:CallOptions.Key<T>

Key identifying option

Annotations
@ExperimentalApi:https://github.com/grpc/grpc-java/issues/1869
@SuppressWarnings:unchecked
getStreamTracerFactoriesback to summary
public List<ClientStreamTracer.Factory> getStreamTracerFactories()

Returns an immutable list of ClientStreamTracerFactorys.

Annotations
@ExperimentalApi:https://github.com/grpc/grpc-java/issues/2861
getWaitForReadyback to summary
pack-priv Boolean getWaitForReady()
isWaitForReadyback to summary
public boolean isWaitForReady()

Returns whether 'wait for ready' option is enabled for the call. 'Fail fast' is the default option for gRPC calls and 'wait for ready' is the opposite to it.

toBuilderback to summary
private static CallOptions.Builder toBuilder(CallOptions other)

Copy CallOptions.

toStringback to summary
public String toString()

Overrides java.lang.Object.toString.

Doc from java.lang.Object.toString.

Returns a string representation of the object.

Returns:String

a string representation of the object.

Annotations
@Override
withAuthorityback to summary
public CallOptions withAuthority(String authority)

Override the HTTP/2 authority the channel claims to be connecting to. This is not generally safe. Overriding allows advanced users to re-use a single Channel for multiple services, even if those services are hosted on different domain names. That assumes the server is virtually hosting multiple domains and is guaranteed to continue doing so. It is rare for a service provider to make such a guarantee. At this time, there is no security verification of the overridden value, such as making sure the authority matches the server's TLS certificate.

Annotations
@ExperimentalApi:https://github.com/grpc/grpc-java/issues/1767
withCallCredentialsback to summary
public CallOptions withCallCredentials(CallCredentials credentials)

Returns a new CallOptions with the given call credentials.

withCompressionback to summary
public CallOptions withCompression(String compressorName)

Sets the compression to use for the call. The compressor must be a valid name known in the CompressorRegistry. By default, the "gzip" compressor will be available.

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.

withDeadlineback to summary
public CallOptions withDeadline(Deadline deadline)

Returns a new CallOptions with the given absolute deadline.

This is mostly used for propagating an existing deadline. withDeadlineAfter is the recommended way of setting a new deadline,

Parameters
deadline:Deadline

the deadline or null for unsetting the deadline.

withDeadlineAfterback to summary
public CallOptions withDeadlineAfter(long duration, TimeUnit unit)

Returns a new CallOptions with a deadline that is after the given duration from now.

withExecutorback to summary
public CallOptions withExecutor(Executor executor)

Returns a new CallOptions with executor to be used instead of the default executor specified with ManagedChannelBuilder#executor.

withMaxInboundMessageSizeback to summary
public CallOptions withMaxInboundMessageSize(int maxSize)

Sets the maximum allowed message size acceptable from the remote peer. If unset, this will default to the value set on the ManagedChannelBuilder#maxInboundMessageSize(int).

Annotations
@ExperimentalApi:https://github.com/grpc/grpc-java/issues/2563
withMaxOutboundMessageSizeback to summary
public CallOptions withMaxOutboundMessageSize(int maxSize)

Sets the maximum allowed message size acceptable sent to the remote peer.

Annotations
@ExperimentalApi:https://github.com/grpc/grpc-java/issues/2563
withOptionback to summary
public <T> CallOptions withOption(CallOptions.Key<T> key, T value)

Sets a custom option. Any existing value for the key is overwritten.

Parameters
key:CallOptions.Key<T>

The option key

value:T

The option value.

Since
1.13.0
withoutWaitForReadyback to summary
public CallOptions withoutWaitForReady()

Disables 'wait for ready' feature for the call. This method should be rarely used because the default is without 'wait for ready'.

withStreamTracerFactoryback to summary
public CallOptions withStreamTracerFactory(ClientStreamTracer.Factory factory)

Returns a new CallOptions with a ClientStreamTracerFactory in addition to the existing factories.

This method doesn't replace existing factories, or try to de-duplicate factories.

Annotations
@ExperimentalApi:https://github.com/grpc/grpc-java/issues/2861
withWaitForReadyback to summary
public CallOptions withWaitForReady()

Enables 'wait for ready' for the call. Wait-for-ready queues the RPC until a connection is available. This may dramatically increase the latency of the RPC, but avoids failing "unnecessarily." The default queues the RPC until an attempt to connect has completed, but fails RPCs without sending them if unable to connect.

io.grpc back to summary

pack-priv Class CallOptions.Builder

extends Object
Class Inheritance

Field Summary

Modifier and TypeField and Description
pack-priv String
pack-priv String
pack-priv CallCredentials
pack-priv Object[][]
pack-priv Deadline
pack-priv Executor
pack-priv Integer
pack-priv Integer
pack-priv List<ClientStreamTracer.Factory>
pack-priv Boolean

Constructor Summary

AccessConstructor and Description
pack-priv

Method Summary

Modifier and TypeMethod and Description
private CallOptions
Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

authorityback to summary
pack-priv String authority
compressorNameback to summary
pack-priv String compressorName
credentialsback to summary
pack-priv CallCredentials credentials
customOptionsback to summary
pack-priv Object[][] customOptions
deadlineback to summary
pack-priv Deadline deadline
executorback to summary
pack-priv Executor executor
maxInboundMessageSizeback to summary
pack-priv Integer maxInboundMessageSize
maxOutboundMessageSizeback to summary
pack-priv Integer maxOutboundMessageSize
streamTracerFactoriesback to summary
pack-priv List<ClientStreamTracer.Factory> streamTracerFactories
waitForReadyback to summary
pack-priv Boolean waitForReady

Constructor Detail

Builderback to summary
pack-priv Builder()

Method Detail

buildback to summary
private CallOptions build()
io.grpc back to summary

public final Class CallOptions.Key<T>

extends Object
Class Inheritance

Key for a key-value pair. Uses reference equality.

Field Summary

Modifier and TypeField and Description
private final String
private final T

Constructor Summary

AccessConstructor and Description
private
Key(String debugString, T defaultValue)

Method Summary

Modifier and TypeMethod and Description
public static <
Key type
T
>
CallOptions.Key<T>

Returns:

Key object
create
(String
a debug string that describes this key.
debugString
)

Factory method for creating instances of Key.

public static <
Key type
T
>
CallOptions.Key<T>

Returns:

Key object
createWithDefault
(String
a debug string that describes this key.
debugString
,
T
default value to return when value for key not set
defaultValue
)

Factory method for creating instances of Key.

public T
getDefault()

Returns the user supplied default value for this key.

public static <
Key type
T
>
CallOptions.Key<T>

Returns:

Key object
of
(String
a string used to describe this key, used for debugging.
debugString
,
T
default value to return when value for key not set
defaultValue
)

Deprecated Use create or createWithDefault instead.
Factory method for creating instances of Key.
public String
toString()

Overrides java.lang.Object.toString.

Returns a string representation of the object.
Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAllwaitwaitwait

Field Detail

debugStringback to summary
private final String debugString
defaultValueback to summary
private final T defaultValue

Constructor Detail

Keyback to summary
private Key(String debugString, T defaultValue)

Method Detail

createback to summary
public static <T> CallOptions.Key<T> create(String debugString)

Factory method for creating instances of Key. The default value of the key is null.

Parameters
<T>
Key type
debugString:String

a debug string that describes this key.

Returns:CallOptions.Key<T>

Key object

Since
1.13.0
createWithDefaultback to summary
public static <T> CallOptions.Key<T> createWithDefault(String debugString, T defaultValue)

Factory method for creating instances of Key.

Parameters
<T>
Key type
debugString:String

a debug string that describes this key.

defaultValue:T

default value to return when value for key not set

Returns:CallOptions.Key<T>

Key object

Since
1.13.0
getDefaultback to summary
public T getDefault()

Returns the user supplied default value for this key.

ofback to summary
public static <T> CallOptions.Key<T> of(String debugString, T defaultValue)

Deprecated

Use create or createWithDefault instead. This method will be removed.

Factory method for creating instances of Key.

Parameters
<T>
Key type
debugString:String

a string used to describe this key, used for debugging.

defaultValue:T

default value to return when value for key not set

Returns:CallOptions.Key<T>

Key object

Annotations
@ExperimentalApi:https://github.com/grpc/grpc-java/issues/1869
@Deprecated
toStringback to summary
public String toString()

Overrides java.lang.Object.toString.

Doc from java.lang.Object.toString.

Returns a string representation of the object.

Returns:String

a string representation of the object.

Annotations
@Override