use of rpc.turbo.transport.server.rest.handler.NettyRestChannelInitializer in project turbo-rpc by hank-whu.
the class NettyRestServer method start.
public void start() throws InterruptedException {
InetSocketAddress inet = new InetSocketAddress(hostPort.host, hostPort.port);
ServerBootstrap bootstrap = new ServerBootstrap();
bootstrap.group(eventLoopGroup);
bootstrap.option(ChannelOption.SO_BACKLOG, 256);
bootstrap.option(ChannelOption.SO_REUSEADDR, true);
if (eventLoopGroup instanceof EpollEventLoopGroup) {
bootstrap.option(EpollChannelOption.SO_REUSEPORT, true);
bootstrap.channel(EpollServerSocketChannel.class);
} else if (eventLoopGroup instanceof NioEventLoopGroup) {
bootstrap.channel(NioServerSocketChannel.class);
}
bootstrap.childHandler(new NettyRestChannelInitializer(invokerFactory, jsonMapper, filters));
bootstrap.childOption(ChannelOption.SO_REUSEADDR, true);
bootstrap.childOption(ChannelOption.SO_KEEPALIVE, true);
channel = bootstrap.bind(inet).sync().channel();
System.out.println("NettyRestServer started. Listening on: " + hostPort);
}
Aggregations