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 |
directExecutor()
Execute application code directly in the transport thread.
|
T |
disableRetry()
Disables the retry and hedging mechanism provided by the gRPC library.
|
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 Attributes |
getNameResolverParams()
Subclasses can override this method to provide additional parameters to
NameResolver.Factory#newNameResolver . |
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 |
loadBalancerFactory(LoadBalancer.Factory loadBalancerFactory)
Provides a custom
LoadBalancer.Factory for the channel. |
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 |
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 |
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, usePlaintext, usePlaintext, useTransportSecurity
protected 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()
ManagedChannelBuilder
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 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)
ManagedChannelBuilder
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.
executor
in class ManagedChannelBuilder<T extends AbstractManagedChannelImplBuilder<T>>
public final T intercept(List<ClientInterceptor> interceptors)
ManagedChannelBuilder
ClientInterceptors.intercept(Channel, List)
, but while
still having access to the original ManagedChannel
.intercept
in class ManagedChannelBuilder<T extends AbstractManagedChannelImplBuilder<T>>
public final T intercept(ClientInterceptor... interceptors)
ManagedChannelBuilder
ClientInterceptors.intercept(Channel,
ClientInterceptor...)
, but while still having access to the original ManagedChannel
.intercept
in class ManagedChannelBuilder<T extends AbstractManagedChannelImplBuilder<T>>
public final T nameResolverFactory(NameResolver.Factory resolverFactory)
ManagedChannelBuilder
NameResolver.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 loadBalancerFactory(LoadBalancer.Factory loadBalancerFactory)
ManagedChannelBuilder
LoadBalancer.Factory
for the channel.
If this method is not called, the builder will use PickFirstBalancerFactory
for the channel.
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.
loadBalancerFactory
in class ManagedChannelBuilder<T extends AbstractManagedChannelImplBuilder<T>>
public final T enableFullStreamDecompression()
ManagedChannelBuilder
EXPERIMENTAL: 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)
ManagedChannelBuilder
DecompressorRegistry.getDefaultInstance()
.decompressorRegistry
in class ManagedChannelBuilder<T extends AbstractManagedChannelImplBuilder<T>>
public final T compressorRegistry(CompressorRegistry registry)
ManagedChannelBuilder
CompressorRegistry.getDefaultInstance()
.compressorRegistry
in class ManagedChannelBuilder<T extends AbstractManagedChannelImplBuilder<T>>
public final T userAgent(@Nullable String userAgent)
ManagedChannelBuilder
User-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)
ManagedChannelBuilder
host: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)
ManagedChannelBuilder
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.
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)
ManagedChannelBuilder
disableRetry()
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)
ManagedChannelBuilder
This 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)
ManagedChannelBuilder
This 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)
ManagedChannelBuilder
This 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()
ManagedChannelBuilder
disableRetry
in class ManagedChannelBuilder<T extends AbstractManagedChannelImplBuilder<T>>
public final T enableRetry()
ManagedChannelBuilder
This method may not work as expected for the current release because retry is not fully implemented yet.
enableRetry
in class ManagedChannelBuilder<T extends AbstractManagedChannelImplBuilder<T>>
public final T setBinaryLog(BinaryLog binlog)
ManagedChannelBuilder
Closeable.close()
.setBinaryLog
in class ManagedChannelBuilder<T extends AbstractManagedChannelImplBuilder<T>>
binlog
- the object to provide logging.public T maxTraceEvents(int maxTraceEvents)
ManagedChannelBuilder
maxTraceEvents
in class ManagedChannelBuilder<T extends AbstractManagedChannelImplBuilder<T>>
protected final T overrideCensusStatsModule(CensusStatsModule censusStats)
protected void setStatsEnabled(boolean value)
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 setTracingEnabled(boolean value)
protected String checkAuthority(String authority)
public ManagedChannel build()
ManagedChannelBuilder
build
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 Attributes getNameResolverParams()
NameResolver.Factory#newNameResolver
. The default implementation returns Attributes.EMPTY
.Copyright © 2018. All rights reserved.