T - The concrete type of this builder.public abstract class AbstractManagedChannelImplBuilder<T extends AbstractManagedChannelImplBuilder<T>> extends ManagedChannelBuilder<T>
| Modifier and Type | Field and Description |
|---|---|
protected TransportTracer.Factory |
transportTracerFactory |
| Modifier | Constructor and Description |
|---|---|
protected |
AbstractManagedChannelImplBuilder(SocketAddress directServerAddress,
String authority) |
protected |
AbstractManagedChannelImplBuilder(String target) |
| Modifier and Type | Method and Description |
|---|---|
ManagedChannel |
build()
Builds a channel using the given parameters.
|
protected abstract ClientTransportFactory |
buildTransportFactory()
Subclasses should override this method to provide the
ClientTransportFactory
appropriate for this channel. |
protected String |
checkAuthority(String authority)
Verifies the authority is valid.
|
T |
compressorRegistry(CompressorRegistry registry)
Set the compression registry for use in the channel.
|
T |
decompressorRegistry(DecompressorRegistry registry)
Set the decompression registry for use in the channel.
|
T |
defaultLoadBalancingPolicy(String policy)
Sets the default load-balancing policy that will be used if the service config doesn't specify
one.
|
T |
defaultServiceConfig(Map<String,?> serviceConfig)
Provides a service config to the channel.
|
T |
directExecutor()
Execute application code directly in the transport thread.
|
T |
disableRetry()
Disables the retry and hedging mechanism provided by the gRPC library.
|
T |
disableServiceConfigLookUp()
Disables service config look-up from the naming system, which is enabled by default.
|
T |
enableFullStreamDecompression()
Enables full-stream decompression of inbound streams.
|
T |
enableRetry()
Enables the retry and hedging mechanism provided by the gRPC library.
|
T |
executor(Executor executor)
Provides a custom executor.
|
static ManagedChannelBuilder<?> |
forAddress(String name,
int port) |
static ManagedChannelBuilder<?> |
forTarget(String target) |
protected int |
getDefaultPort()
Subclasses can override this method to provide a default port to
NameResolver for use
in cases where the target string doesn't include a port. |
T |
idleTimeout(long value,
TimeUnit unit)
Set the duration without ongoing RPCs before going to idle mode.
|
T |
intercept(ClientInterceptor... interceptors)
Adds interceptors that will be called before the channel performs its real work.
|
T |
intercept(List<ClientInterceptor> interceptors)
Adds interceptors that will be called before the channel performs its real work.
|
T |
maxHedgedAttempts(int maxHedgedAttempts)
Sets max number of hedged attempts.
|
protected int |
maxInboundMessageSize() |
T |
maxInboundMessageSize(int max)
Sets the maximum message size allowed for a single gRPC frame.
|
T |
maxRetryAttempts(int maxRetryAttempts)
Sets max number of retry attempts.
|
T |
maxTraceEvents(int maxTraceEvents)
Sets the maximum number of channel trace events to keep in the tracer for each channel or
subchannel.
|
T |
nameResolverFactory(NameResolver.Factory resolverFactory)
Provides a custom
NameResolver.Factory for the channel. |
T |
overrideAuthority(String authority)
Overrides the authority used with TLS and HTTP virtual hosting.
|
protected T |
overrideCensusStatsModule(CensusStatsModule censusStats)
Override the default stats implementation.
|
T |
perRpcBufferLimit(long bytes)
Sets the per RPC buffer limit in bytes used for retry.
|
T |
proxyDetector(ProxyDetector proxyDetector)
Sets the proxy detector to be used in addresses name resolution.
|
T |
retryBufferSize(long bytes)
Sets the retry buffer size in bytes.
|
T |
setBinaryLog(BinaryLog binlog)
Sets the BinaryLog object that this channel should log to.
|
protected void |
setStatsEnabled(boolean value)
Disable or enable stats features.
|
protected void |
setStatsRecordFinishedRpcs(boolean value)
Disable or enable stats recording for RPC completions.
|
protected void |
setStatsRecordRealTimeMetrics(boolean value)
Disable or enable real-time metrics recording.
|
protected void |
setStatsRecordStartedRpcs(boolean value)
Disable or enable stats recording for RPC upstarts.
|
protected void |
setTracingEnabled(boolean value)
Disable or enable tracing features.
|
T |
userAgent(String userAgent)
Provides a custom
User-Agent for the application. |
keepAliveTime, keepAliveTimeout, keepAliveWithoutCalls, maxInboundMetadataSize, usePlaintext, usePlaintext, useTransportSecurityprotected TransportTracer.Factory transportTracerFactory
protected AbstractManagedChannelImplBuilder(String target)
protected AbstractManagedChannelImplBuilder(SocketAddress directServerAddress, String authority)
public static ManagedChannelBuilder<?> forAddress(String name, int port)
public static ManagedChannelBuilder<?> forTarget(String target)
public T maxInboundMessageSize(int max)
maxInboundMessageSize in class ManagedChannelBuilder<T extends AbstractManagedChannelImplBuilder<T>>max - the maximum number of bytes a single message can be.protected final int maxInboundMessageSize()
public final T directExecutor()
ManagedChannelBuilderDepending 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 ManagedChannelBuilder.executor(Executor) and
passing in a direct executor. However, this is the preferred way as it may allow the transport
to perform special optimizations.
directExecutor in class ManagedChannelBuilder<T extends AbstractManagedChannelImplBuilder<T>>public final T executor(Executor executor)
ManagedChannelBuilderIt'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.
executor in class ManagedChannelBuilder<T extends AbstractManagedChannelImplBuilder<T>>public final T intercept(List<ClientInterceptor> interceptors)
ManagedChannelBuilderClientInterceptors.intercept(Channel, List), but while
still having access to the original ManagedChannel. Interceptors run in the reverse
order in which they are added, just as with consecutive calls to ClientInterceptors.intercept().intercept in class ManagedChannelBuilder<T extends AbstractManagedChannelImplBuilder<T>>public final T intercept(ClientInterceptor... interceptors)
ManagedChannelBuilderClientInterceptors.intercept(Channel,
ClientInterceptor...), but while still having access to the original ManagedChannel.
Interceptors run in the reverse order in which they are added, just as with consecutive calls
to ClientInterceptors.intercept().intercept in class ManagedChannelBuilder<T extends AbstractManagedChannelImplBuilder<T>>public final T nameResolverFactory(NameResolver.Factory resolverFactory)
ManagedChannelBuilderNameResolver.Factory for the channel. If this method is not called,
the builder will try the providers listed by NameResolverProvider.providers() for the
given target.
This method should rarely be used, as name resolvers should provide a NameResolverProvider and users rely on service loading to find implementations in the class
path. That allows application's configuration to easily choose the name resolver via the
'target' string passed to ManagedChannelBuilder.forTarget(String).
nameResolverFactory in class ManagedChannelBuilder<T extends AbstractManagedChannelImplBuilder<T>>public final T defaultLoadBalancingPolicy(String policy)
ManagedChannelBuilderPolicy implementations are looked up in the
default LoadBalancerRegistry.
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.
defaultLoadBalancingPolicy in class ManagedChannelBuilder<T extends AbstractManagedChannelImplBuilder<T>>public final T enableFullStreamDecompression()
ManagedChannelBuilderEXPERIMENTAL: This method is here to enable an experimental feature, and may be changed or removed once the feature is stable.
enableFullStreamDecompression in class ManagedChannelBuilder<T extends AbstractManagedChannelImplBuilder<T>>public final T decompressorRegistry(DecompressorRegistry registry)
ManagedChannelBuilderDecompressorRegistry.getDefaultInstance().decompressorRegistry in class ManagedChannelBuilder<T extends AbstractManagedChannelImplBuilder<T>>public final T compressorRegistry(CompressorRegistry registry)
ManagedChannelBuilderCompressorRegistry.getDefaultInstance().compressorRegistry in class ManagedChannelBuilder<T extends AbstractManagedChannelImplBuilder<T>>public final T userAgent(@Nullable String userAgent)
ManagedChannelBuilderUser-Agent for the application.
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.
userAgent in class ManagedChannelBuilder<T extends AbstractManagedChannelImplBuilder<T>>public final T overrideAuthority(String authority)
ManagedChannelBuilderhost:port.
This method is intended for testing, but may safely be used outside of tests as an alternative to DNS overrides.
overrideAuthority in class ManagedChannelBuilder<T extends AbstractManagedChannelImplBuilder<T>>public final T idleTimeout(long value, TimeUnit unit)
ManagedChannelBuilderIn 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.
By default the channel will never go to idle mode after it leaves the initial idle mode.
This is an advisory option. Do not rely on any specific behavior related to this option.
idleTimeout in class ManagedChannelBuilder<T extends AbstractManagedChannelImplBuilder<T>>public final T maxRetryAttempts(int maxRetryAttempts)
ManagedChannelBuilderdisableRetry() because the former does not disable
transparent retry.
This method may not work as expected for the current release because retry is not fully implemented yet.
maxRetryAttempts in class ManagedChannelBuilder<T extends AbstractManagedChannelImplBuilder<T>>public final T maxHedgedAttempts(int maxHedgedAttempts)
ManagedChannelBuilderThis method may not work as expected for the current release because retry is not fully implemented yet.
maxHedgedAttempts in class ManagedChannelBuilder<T extends AbstractManagedChannelImplBuilder<T>>public final T retryBufferSize(long bytes)
ManagedChannelBuilderThis method may not work as expected for the current release because retry is not fully implemented yet.
retryBufferSize in class ManagedChannelBuilder<T extends AbstractManagedChannelImplBuilder<T>>public final T perRpcBufferLimit(long bytes)
ManagedChannelBuilderThis method may not work as expected for the current release because retry is not fully implemented yet.
perRpcBufferLimit in class ManagedChannelBuilder<T extends AbstractManagedChannelImplBuilder<T>>public final T disableRetry()
ManagedChannelBuilderdisableRetry in class ManagedChannelBuilder<T extends AbstractManagedChannelImplBuilder<T>>public final T enableRetry()
ManagedChannelBuilderFor the current release, this method may have a side effect that disables Census stats and tracing. Hedging support is not implemented yet.
enableRetry in class ManagedChannelBuilder<T extends AbstractManagedChannelImplBuilder<T>>public final T setBinaryLog(BinaryLog binlog)
ManagedChannelBuilderCloseable.close().setBinaryLog in class ManagedChannelBuilder<T extends AbstractManagedChannelImplBuilder<T>>binlog - the object to provide logging.public T maxTraceEvents(int maxTraceEvents)
ManagedChannelBuildermaxTraceEvents in class ManagedChannelBuilder<T extends AbstractManagedChannelImplBuilder<T>>protected final T overrideCensusStatsModule(CensusStatsModule censusStats)
public T proxyDetector(@Nullable ProxyDetector proxyDetector)
ManagedChannelBuildernull is passed
the default proxy detector will be used. For how proxies work in gRPC, please refer to the
documentation on ProxyDetector.proxyDetector in class ManagedChannelBuilder<T extends AbstractManagedChannelImplBuilder<T>>public T defaultServiceConfig(@Nullable Map<String,?> serviceConfig)
ManagedChannelBuilderManagedChannelBuilder.disableServiceConfigLookUp()). The argument
serviceConfig is a nested map representing a Json object in the most natural way:
| Json entry | Java Type |
| object | Map |
| array | List |
| string | String |
| number | Double |
| boolean | Boolean |
| null | null |
If null is passed, then there will be no default service config.
defaultServiceConfig in class ManagedChannelBuilder<T extends AbstractManagedChannelImplBuilder<T>>public T disableServiceConfigLookUp()
ManagedChannelBuilderdisableServiceConfigLookUp in class ManagedChannelBuilder<T extends AbstractManagedChannelImplBuilder<T>>protected void setStatsEnabled(boolean value)
For the current release, calling setStatsEnabled(true) may have a side effect that
disables retry.
protected void setStatsRecordStartedRpcs(boolean value)
setStatsEnabled(boolean) is set to true. Enabled by default.protected void setStatsRecordFinishedRpcs(boolean value)
setStatsEnabled(boolean) is set to true. Enabled by default.protected void setStatsRecordRealTimeMetrics(boolean value)
setStatsEnabled(boolean) is
set to true. Disabled by default.protected void setTracingEnabled(boolean value)
For the current release, calling setTracingEnabled(true) may have a side effect that
disables retry.
protected String checkAuthority(String authority)
public ManagedChannel build()
ManagedChannelBuilderbuild in class ManagedChannelBuilder<T extends AbstractManagedChannelImplBuilder<T>>protected abstract ClientTransportFactory buildTransportFactory()
ClientTransportFactory
appropriate for this channel. This method is meant for Transport implementors and should not
be used by normal users.protected int getDefaultPort()
NameResolver for use
in cases where the target string doesn't include a port. The default implementation returns
GrpcUtil.DEFAULT_PORT_SSL.