实践Reactor Netty

reactor-netty

HttpServer

1
2
3
4
5
HttpServer.create()
	.host("0.0.0.0")
 	.handle((req, res) -> res.sendString(Flux.just("hello"))
    .bind()
	.block();

TcpServer

TcpServerRunOn

1
2
3
4
5
6
7
8
9
10
static void configure(ServerBootstrap b,
			boolean preferNative,
			LoopResources resources) {

		EventLoopGroup selectorGroup = resources.onServerSelect(preferNative);
		EventLoopGroup elg = resources.onServer(preferNative);

		b.group(selectorGroup, elg)
		 .channel(resources.onServerChannel(elg));
	}

参考