ManagedChannel instances.
| Access | Constructor and Description |
|---|---|
| public |
| Modifier and Type | Method and Description |
|---|---|
| public abstract ManagedChannel | |
| public abstract T | Returns: thisSet the compression registry for use in the channel. |
| public abstract T | Returns: thisSet the decompression registry for use in the channel. |
| public T | Returns: thisSets the default load-balancing policy that will be used if the service config doesn't specify one. |
| public T | Returns: thisProvides a service config to the channel. |
| public abstract T | |
| public T | |
| public T | Returns: thisDisables service config look-up from the naming system, which is enabled by default. |
| public T | |
| public T | Returns: thisEnables the retry and hedging subsystem which will use per-method configuration. |
| public abstract T | |
| public static ManagedChannelBuilder | |
| public static ManagedChannelBuilder | forTarget(String target)
Creates a channel with a target string, which can be either a valid |
| public abstract T | Returns: thisSet the duration without ongoing RPCs before going to idle mode. |
| public abstract T | Returns: thisAdds interceptors that will be called before the channel performs its real work. |
| public abstract T | Returns: thisAdds interceptors that will be called before the channel performs its real work. |
| public T | keepAliveTime(long keepAliveTime, TimeUnit timeUnit)
Sets the time without read activity before sending a keepalive ping. |
| public T | keepAliveTimeout(long keepAliveTimeout, TimeUnit timeUnit)
Sets the time waiting for read activity after sending a keepalive ping. |
| public T | keepAliveWithoutCalls(boolean enable)
Sets whether keepalive will be performed when there are no outstanding RPC on a connection. |
| public T | Returns: thisSets the maximum number of hedged attempts that may be configured by the service config. |
| public T | Returns: thisthe maximum number of bytes a single message can be. bytes)Sets the maximum message size allowed to be received on the channel. |
| public T | Returns: thisthe maximum size of received metadata bytes)Sets the maximum size of metadata allowed to be received. |
| public T | Returns: thisSets the maximum number of retry attempts that may be configured by the service config. |
| public T | Returns: thisSets the maximum number of channel trace events to keep in the tracer for each channel or subchannel. |
| public abstract T | Returns: this
Deprecated
Most usages should use a globally-registered
Provides a custom NameResolverProvider instead,
with either the SPI mechanism or NameResolverRegistry#register.
NameResolver. for the channel.
|
| public T | Returns: thisProvides a custom executor that will be used for operations that block or are expensive, to avoid blocking asynchronous code paths. |
| public abstract T | Returns: thisOverrides the authority used with TLS and HTTP virtual hosting. |
| public T | |
| public T | Returns: thisSets the proxy detector to be used in addresses name resolution. |
| public T | |
| public T | Returns: thisthe object to provide logging. binaryLog)Sets the BinaryLog object that this channel should log to. |
| private T | |
| public T | |
| public abstract T | |
| public T |
| ManagedChannelBuilder | back to summary |
|---|---|
| public ManagedChannelBuilder() | |
| build | back to summary |
|---|---|
| public abstract ManagedChannel build() Builds a channel using the given parameters.
| |
| compressorRegistry | back to summary |
|---|---|
| public abstract T compressorRegistry(CompressorRegistry registry) Set the compression registry for use in the channel. This is an advanced API call and
shouldn't be used unless you are using custom message encoding. The default supported
compressors are in
| |
| decompressorRegistry | back to summary |
|---|---|
| public abstract T decompressorRegistry(DecompressorRegistry registry) Set the decompression registry for use in the channel. This is an advanced API call and
shouldn't be used unless you are using custom message encoding. The default supported
decompressors are in
| |
| defaultLoadBalancingPolicy | back to summary |
|---|---|
| public T defaultLoadBalancingPolicy(String policy) Sets the default load-balancing policy that will be used if the service config doesn't specify one. If not set, the default will be the "pick_first" policy. Policy implementations are looked up in the
This method is implemented by all stock channel builders that are shipped with gRPC, but may not be implemented by custom channel builders, in which case this method will throw.
| |
| defaultServiceConfig | back to summary | ||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| public T defaultServiceConfig(Map<String, ?> serviceConfig) Provides a service config to the channel. The channel will use the default service config when
the name resolver provides no service config or if the channel disables lookup service config
from name resolver (see
If null is passed, then there will be no default service config. Your preferred JSON parser may not produce results in the format expected. For such cases, you can convert its output. For example, if your parser produces Integers and other Numbers in addition to Double:
| |||||||||||||||
| directExecutor | back to summary |
|---|---|
| public abstract T directExecutor() Execute application code directly in the transport thread. Depending on the underlying transport, using a direct executor may lead to substantial performance improvements. However, it also requires the application to not block under any circumstances. Calling this method is semantically equivalent to calling
| |
| disableRetry | back to summary |
|---|---|
| public T disableRetry() Disables the retry and hedging subsystem provided by the gRPC library. This is designed for the case when users have their own retry implementation and want to avoid their own retry taking place simultaneously with the gRPC library layer retry.
| |
| disableServiceConfigLookUp | back to summary |
|---|---|
| public T disableServiceConfigLookUp() Disables service config look-up from the naming system, which is enabled by default.
| |
| enableFullStreamDecompression | back to summary |
|---|---|
| public T enableFullStreamDecompression() Enables full-stream decompression of inbound streams. This will cause the channel's outbound headers to advertise support for GZIP compressed streams, and gRPC servers which support the feature may respond with a GZIP compressed stream. EXPERIMENTAL: This method is here to enable an experimental feature, and may be changed or removed once the feature is stable.
| |
| enableRetry | back to summary |
|---|---|
| public T enableRetry() Enables the retry and hedging subsystem which will use
per-method configuration. If a method is unconfigured, it will be limited to
transparent retries, which are safe for non-idempotent RPCs. Service config is ideally provided
by the name resolver, but may also be specified via
| |
| executor | back to summary |
|---|---|
| public abstract T executor(Executor executor) Provides a custom executor. It's an optional parameter. If the user has not provided an executor when the channel is built, the builder will use a static cached thread pool. The channel won't take ownership of the given executor. It's caller's responsibility to shut down the executor when it's desired.
| |
| forAddress | back to summary |
|---|---|
| public static ManagedChannelBuilder Creates a channel with the target's address and port number. Note that there is an open JDK bug on
| |
| forTarget | back to summary |
|---|---|
| public static ManagedChannelBuilder Creates a channel with a target string, which can be either a valid A
An authority string will be converted to a
Note that there is an open JDK bug on
| |
| idleTimeout | back to summary |
|---|---|
| public abstract T idleTimeout(long value, TimeUnit unit) Set the duration without ongoing RPCs before going to idle mode. In idle mode the channel shuts down all connections, the NameResolver and the LoadBalancer. A new RPC would take the channel out of idle mode. A channel starts in idle mode. Defaults to 30 minutes. This is an advisory option. Do not rely on any specific behavior related to this option.
| |
| intercept | back to summary |
|---|---|
| public abstract T intercept(List<ClientInterceptor> interceptors) Adds interceptors that will be called before the channel performs its real work. This is
functionally equivalent to using
| |
| intercept | back to summary |
|---|---|
| public abstract T intercept(ClientInterceptor... interceptors) Adds interceptors that will be called before the channel performs its real work. This is
functionally equivalent to using
| |
| keepAliveTime | back to summary |
|---|---|
| public T keepAliveTime(long keepAliveTime, TimeUnit timeUnit) Sets the time without read activity before sending a keepalive ping. An unreasonably small
value might be increased, and Clients must receive permission from the service owner before enabling this option. Keepalives can increase the load on services and are commonly "invisible" making it hard to notice when they are causing excessive load. Clients are strongly encouraged to use only as small of a value as necessary.
| |
| keepAliveTimeout | back to summary |
|---|---|
| public T keepAliveTimeout(long keepAliveTimeout, TimeUnit timeUnit) Sets the time waiting for read activity after sending a keepalive ping. If the time expires without any read activity on the connection, the connection is considered dead. An unreasonably small value might be increased. Defaults to 20 seconds. This value should be at least multiple times the RTT to allow for lost packets.
| |
| keepAliveWithoutCalls | back to summary |
|---|---|
| public T keepAliveWithoutCalls(boolean enable) Sets whether keepalive will be performed when there are no outstanding RPC on a connection.
Defaults to Clients must receive permission from the service owner before enabling this option.
Keepalives on unused connections can easilly accidentally consume a considerable amount of
bandwidth and CPU.
| |
| maxHedgedAttempts | back to summary |
|---|---|
| public T maxHedgedAttempts(int maxHedgedAttempts) Sets the maximum number of hedged attempts that may be configured by the service config. If the service config specifies a larger value it will be reduced to this value. This method may not work as expected for the current release because retry is not fully implemented yet.
| |
| maxInboundMessageSize | back to summary |
|---|---|
| public T maxInboundMessageSize(int bytes) Sets the maximum message size allowed to be received on the channel. If not called, defaults to 4 MiB. The default provides protection to clients who haven't considered the possibility of receiving large messages while trying to be large enough to not be hit in normal usage. This method is advisory, and implementations may decide to not enforce this. Currently,
the only known transport to not enforce this is
| |
| maxInboundMetadataSize | back to summary |
|---|---|
| public T maxInboundMetadataSize(int bytes) Sets the maximum size of metadata allowed to be received. This is cumulative size of the metadata. The precise calculation is implementation-dependent, but implementations are encouraged to follow the calculation used for HTTP/2's SETTINGS_MAX_HEADER_LIST_SIZE. It sums the bytes from each entry's key and value, plus 32 bytes of overhead per entry.
| |
| maxRetryAttempts | back to summary |
|---|---|
| public T maxRetryAttempts(int maxRetryAttempts) Sets the maximum number of retry attempts that may be configured by the service config. If the
service config specifies a larger value it will be reduced to this value. Setting this number
to zero is not effectively the same as This method may not work as expected for the current release because retry is not fully implemented yet.
| |
| maxTraceEvents | back to summary |
|---|---|
| public T maxTraceEvents(int maxTraceEvents) Sets the maximum number of channel trace events to keep in the tracer for each channel or subchannel. If set to 0, channel tracing is effectively disabled.
| |
| nameResolverFactory | back to summary |
|---|---|
| public abstract T nameResolverFactory(NameResolver. Deprecated Most usages should use a globally-registered Provides a custom This method should rarely be used, as name resolvers should provide a
| |
| offloadExecutor | back to summary |
|---|---|
| public T offloadExecutor(Executor executor) Provides a custom executor that will be used for operations that block or are expensive, to avoid blocking asynchronous code paths. For example, DNS queries and OAuth token fetching over HTTP could use this executor. It's an optional parameter. If the user has not provided an executor when the channel is built, the builder will use a static cached thread pool. The channel won't take ownership of the given executor. It's caller's responsibility to shut down the executor when it's desired.
| |
| overrideAuthority | back to summary |
|---|---|
| public abstract T overrideAuthority(String authority) Overrides the authority used with TLS and HTTP virtual hosting. It does not change what host is
actually connected to. Is commonly in the form If the channel builder overrides authority, any authority override from name resolution
result (via This method is intended for testing, but may safely be used outside of tests as an alternative to DNS overrides.
| |
| perRpcBufferLimit | back to summary |
|---|---|
| public T perRpcBufferLimit(long bytes) Sets the per RPC buffer limit in bytes used for retry. The RPC is not retriable if its buffer limit is exceeded. The implementation may only estimate the buffer size being used rather than count the exact physical memory allocated. It does not have any effect if retry is disabled by the client. This method may not work as expected for the current release because retry is not fully implemented yet.
| |
| proxyDetector | back to summary |
|---|---|
| public T proxyDetector(ProxyDetector proxyDetector) Sets the proxy detector to be used in addresses name resolution. If
| |
| retryBufferSize | back to summary |
|---|---|
| public T retryBufferSize(long bytes) Sets the retry buffer size in bytes. If the buffer limit is exceeded, no RPC could retry at the moment, and in hedging case all hedges but one of the same RPC will cancel. The implementation may only estimate the buffer size being used rather than count the exact physical memory allocated. The method does not have any effect if retry is disabled by the client. This method may not work as expected for the current release because retry is not fully implemented yet.
| |
| setBinaryLog | back to summary |
|---|---|
| public T setBinaryLog(BinaryLog binaryLog) Sets the BinaryLog object that this channel should log to. The channel does not take
ownership of the object, and users are responsible for calling
| |
| thisT | back to summary |
|---|---|
| private T thisT() Returns the correctly typed version of the builder. | |
| usePlaintext | back to summary |
|---|---|
| public T usePlaintext() Use of a plaintext connection to the server. By default a secure connection mechanism such as TLS will be used. Should only be used for testing or for APIs where the use of such API or the data exchanged is not sensitive. This assumes prior knowledge that the target of this channel is using plaintext. It will not perform HTTP/1.1 upgrades.
| |
| userAgent | back to summary |
|---|---|
| public abstract T userAgent(String userAgent) Provides a custom It's an optional parameter. The library will provide a user agent independent of this option. If provided, the given agent will prepend the library's user agent information.
| |
| useTransportSecurity | back to summary |
|---|---|
| public T useTransportSecurity() Makes the client use TLS. Note this is enabled by default. It is recommended to use the
| |