@ExperimentalApi(value="https://github.com/grpc/grpc-java/issues/1784") public final class NettyChannelBuilder extends io.grpc.internal.AbstractManagedChannelImplBuilder<NettyChannelBuilder>
Modifier and Type | Field and Description |
---|---|
static int |
DEFAULT_FLOW_CONTROL_WINDOW |
Modifier and Type | Method and Description |
---|---|
protected io.grpc.internal.ClientTransportFactory |
buildTransportFactory() |
NettyChannelBuilder |
channelType(Class<? extends Channel> channelType)
Specifies the channel type to use, by default we use
NioSocketChannel . |
protected String |
checkAuthority(String authority) |
NettyChannelBuilder |
enableKeepAlive(boolean enable)
Deprecated.
|
NettyChannelBuilder |
enableKeepAlive(boolean enable,
long keepAliveTime,
TimeUnit delayUnit,
long keepAliveTimeout,
TimeUnit timeoutUnit)
Deprecated.
|
NettyChannelBuilder |
eventLoopGroup(EventLoopGroup eventLoopGroup)
Provides an EventGroupLoop to be used by the netty transport.
|
NettyChannelBuilder |
flowControlWindow(int flowControlWindow)
Sets the flow control window in bytes.
|
static NettyChannelBuilder |
forAddress(SocketAddress serverAddress)
Creates a new builder with the given server address.
|
static NettyChannelBuilder |
forAddress(String host,
int port)
Creates a new builder with the given host and port.
|
static NettyChannelBuilder |
forTarget(String target)
Creates a new builder with the given target string that will be resolved by
NameResolver . |
protected io.grpc.Attributes |
getNameResolverParams() |
NettyChannelBuilder |
keepAliveTime(long keepAliveTime,
TimeUnit timeUnit)
Sets the time without read activity before sending a keepalive ping.
|
NettyChannelBuilder |
keepAliveTimeout(long keepAliveTimeout,
TimeUnit timeUnit)
Sets the time waiting for read activity after sending a keepalive ping.
|
NettyChannelBuilder |
keepAliveWithoutCalls(boolean enable)
Sets whether keepalive will be performed when there are no outstanding RPC on a connection.
|
NettyChannelBuilder |
maxHeaderListSize(int maxHeaderListSize)
Sets the maximum size of header list allowed to be received on the channel.
|
NettyChannelBuilder |
maxMessageSize(int maxMessageSize)
Deprecated.
Use
AbstractManagedChannelImplBuilder.maxInboundMessageSize instead |
NettyChannelBuilder |
negotiationType(NegotiationType type)
Sets the negotiation type for the HTTP/2 connection.
|
NettyChannelBuilder |
sslContext(SslContext sslContext)
SSL/TLS context to use instead of the system default.
|
NettyChannelBuilder |
usePlaintext(boolean skipNegotiation)
|
<T> NettyChannelBuilder |
withOption(ChannelOption<T> option,
T value)
Specifies a channel option.
|
build, compressorRegistry, decompressorRegistry, directExecutor, executor, idleTimeout, intercept, intercept, loadBalancerFactory, maxInboundMessageSize, maxInboundMessageSize, nameResolverFactory, overrideAuthority, recordsStats, setEnableStatsTagPropagation, setEnableTracing, statsContextFactory, userAgent
public static final int DEFAULT_FLOW_CONTROL_WINDOW
@CheckReturnValue public static NettyChannelBuilder forAddress(SocketAddress serverAddress)
forAddress(String, int)
should
generally be preferred over this method, since that API permits delaying DNS lookups and
noticing changes to DNS.@CheckReturnValue public static NettyChannelBuilder forAddress(String host, int port)
@CheckReturnValue public static NettyChannelBuilder forTarget(String target)
NameResolver
.public NettyChannelBuilder channelType(Class<? extends Channel> channelType)
NioSocketChannel
.public <T> NettyChannelBuilder withOption(ChannelOption<T> option, T value)
public NettyChannelBuilder negotiationType(NegotiationType type)
Default: TLS
public NettyChannelBuilder eventLoopGroup(@Nullable EventLoopGroup eventLoopGroup)
It's an optional parameter. If the user has not provided an EventGroupLoop when the channel is built, the builder will use the default one which is static.
The channel won't take ownership of the given EventLoopGroup. It's caller's responsibility to shut it down when it's desired.
public NettyChannelBuilder sslContext(SslContext sslContext)
GrpcSslContexts
, but options could have been overridden.public NettyChannelBuilder flowControlWindow(int flowControlWindow)
DEFAULT_FLOW_CONTROL_WINDOW
).@Deprecated public NettyChannelBuilder maxMessageSize(int maxMessageSize)
AbstractManagedChannelImplBuilder.maxInboundMessageSize
insteadpublic NettyChannelBuilder maxHeaderListSize(int maxHeaderListSize)
GrpcUtil.DEFAULT_MAX_HEADER_LIST_SIZE
.public NettyChannelBuilder usePlaintext(boolean skipNegotiation)
usePlaintext
in class io.grpc.ManagedChannelBuilder<NettyChannelBuilder>
@Deprecated public final NettyChannelBuilder enableKeepAlive(boolean enable)
keepAliveTime(long, java.util.concurrent.TimeUnit)
and keepAliveTimeout(long, java.util.concurrent.TimeUnit)
instead@Deprecated public final NettyChannelBuilder enableKeepAlive(boolean enable, long keepAliveTime, TimeUnit delayUnit, long keepAliveTimeout, TimeUnit timeoutUnit)
keepAliveTime(long, java.util.concurrent.TimeUnit)
and keepAliveTimeout(long, java.util.concurrent.TimeUnit)
insteadpublic NettyChannelBuilder keepAliveTime(long keepAliveTime, TimeUnit timeUnit)
Long.MAX_VALUE
nano seconds or an unreasonably large
value will disable keepalive. Defaults to infinite.
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.
public NettyChannelBuilder keepAliveTimeout(long keepAliveTimeout, TimeUnit timeUnit)
This value should be at least multiple times the RTT to allow for lost packets.
public NettyChannelBuilder keepAliveWithoutCalls(boolean enable)
false
.
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.
keepAliveTime(long, TimeUnit)
@CheckReturnValue @Internal protected io.grpc.internal.ClientTransportFactory buildTransportFactory()
buildTransportFactory
in class io.grpc.internal.AbstractManagedChannelImplBuilder<NettyChannelBuilder>
@CheckReturnValue protected io.grpc.Attributes getNameResolverParams()
getNameResolverParams
in class io.grpc.internal.AbstractManagedChannelImplBuilder<NettyChannelBuilder>
@CheckReturnValue @Internal protected String checkAuthority(String authority)
checkAuthority
in class io.grpc.internal.AbstractManagedChannelImplBuilder<NettyChannelBuilder>