@ExperimentalApi(value="There is no plan to make this API stable, given transport API instability") public final class NettyServerBuilder extends io.grpc.internal.AbstractServerImplBuilder<NettyServerBuilder>
Modifier and Type | Field and Description |
---|---|
static int |
DEFAULT_FLOW_CONTROL_WINDOW |
Modifier and Type | Method and Description |
---|---|
NettyServerBuilder |
bossEventLoopGroup(EventLoopGroup group)
Provides the boss EventGroupLoop to the server.
|
protected NettyServer |
buildTransportServer() |
NettyServerBuilder |
channelType(Class<? extends ServerChannel> channelType)
Specify the channel type to use, by default we use
NioServerSocketChannel . |
NettyServerBuilder |
flowControlWindow(int flowControlWindow)
Sets the HTTP/2 flow control window.
|
static NettyServerBuilder |
forAddress(SocketAddress address)
Creates a server builder configured with the given
SocketAddress . |
static NettyServerBuilder |
forPort(int port)
Creates a server builder that will bind to the given port.
|
static NettyServerBuilder |
forRegistryAndPort(io.grpc.HandlerRegistry registry,
int port)
Creates a server builder that will bind to the given port and use the
HandlerRegistry
for call dispatching. |
NettyServerBuilder |
maxConcurrentCallsPerConnection(int maxCalls)
The maximum number of concurrent calls permitted for each incoming connection.
|
NettyServerBuilder |
maxMessageSize(int maxMessageSize)
Sets the maximum message size allowed to be received on the server.
|
NettyServerBuilder |
sslContext(SslContext sslContext)
Sets the TLS context to use for encryption.
|
NettyServerBuilder |
useTransportSecurity(File certChain,
File privateKey) |
NettyServerBuilder |
workerEventLoopGroup(EventLoopGroup group)
Provides the worker EventGroupLoop to the server.
|
public static final int DEFAULT_FLOW_CONTROL_WINDOW
public static NettyServerBuilder forPort(int port)
port
- the port on which the server is to be bound.public static NettyServerBuilder forRegistryAndPort(io.grpc.HandlerRegistry registry, int port)
HandlerRegistry
for call dispatching.registry
- the registry of handlers used for dispatching incoming calls.port
- the port on which to the server is to be bound.public static NettyServerBuilder forAddress(SocketAddress address)
SocketAddress
.address
- the socket address on which the server is to be bound.public NettyServerBuilder channelType(Class<? extends ServerChannel> channelType)
NioServerSocketChannel
.public NettyServerBuilder bossEventLoopGroup(EventLoopGroup group)
It's an optional parameter. If the user has not provided one when the server is built, the builder will use the default one which is static.
The server won't take ownership of the given EventLoopGroup. It's caller's responsibility to shut it down when it's desired.
Grpc uses non-daemon Thread
s by default and thus a Server
will
continue to run even after the main thread has terminated. However, users have to be cautious
when providing their own EventLoopGroup
s.
For example, Netty's EventLoopGroup
s use daemon threads by default
and thus an application with only daemon threads running besides the main thread will exit as
soon as the main thread completes.
A simple solution to this problem is to call Server.awaitTermination()
to
keep the main thread alive until the server has terminated.
public NettyServerBuilder workerEventLoopGroup(EventLoopGroup group)
It's an optional parameter. If the user has not provided one when the server is built, the builder will create one.
The server won't take ownership of the given EventLoopGroup. It's caller's responsibility to shut it down when it's desired.
Grpc uses non-daemon Thread
s by default and thus a Server
will
continue to run even after the main thread has terminated. However, users have to be cautious
when providing their own EventLoopGroup
s.
For example, Netty's EventLoopGroup
s use daemon threads by default
and thus an application with only daemon threads running besides the main thread will exit as
soon as the main thread completes.
A simple solution to this problem is to call Server.awaitTermination()
to
keep the main thread alive until the server has terminated.
public NettyServerBuilder sslContext(SslContext sslContext)
GrpcSslContexts
, but options could have been overridden.public NettyServerBuilder maxConcurrentCallsPerConnection(int maxCalls)
public NettyServerBuilder flowControlWindow(int flowControlWindow)
DEFAULT_FLOW_CONTROL_WINDOW
).public NettyServerBuilder maxMessageSize(int maxMessageSize)
protected NettyServer buildTransportServer()
buildTransportServer
in class io.grpc.internal.AbstractServerImplBuilder<NettyServerBuilder>
public NettyServerBuilder useTransportSecurity(File certChain, File privateKey)
useTransportSecurity
in class io.grpc.ServerBuilder<NettyServerBuilder>