connectionProvider = ConnectionProvider.newConnection(); } else if (pool.getType() == FIXED) { connectionProvider = ConnectionProvider.fixed(pool.getName(),
@Override protected Mono<? extends Connection> bind(Bootstrap b) { //Default group and channel if (b.config() .group() == null) { UdpResources loopResources = UdpResources.get(); EventLoopGroup elg = loopResources.onClient(LoopResources.DEFAULT_NATIVE); b.group(elg) .channel(loopResources.onDatagramChannel(elg)); } return ConnectionProvider.newConnection() .acquire(b); } }
@Override protected Mono<? extends Connection> connect(Bootstrap b) { //Default group and channel if (b.config() .group() == null) { UdpResources loopResources = UdpResources.get(); EventLoopGroup elg = loopResources.onClient(LoopResources.DEFAULT_NATIVE); b.group(elg) .channel(loopResources.onDatagramChannel(elg)); } return ConnectionProvider.newConnection() .acquire(b); } }
@Override protected Mono<? extends Connection> connect(Bootstrap b) { //Default group and channel if (b.config() .group() == null) { UdpResources loopResources = UdpResources.get(); EventLoopGroup elg = loopResources.onClient(LoopResources.DEFAULT_NATIVE); b.group(elg) .channel(loopResources.onDatagramChannel(elg)); } return ConnectionProvider.newConnection() .acquire(b); } }
@Override protected Mono<? extends Connection> bind(Bootstrap b) { //Default group and channel if (b.config() .group() == null) { UdpResources loopResources = UdpResources.get(); EventLoopGroup elg = loopResources.onClient(LoopResources.DEFAULT_NATIVE); b.group(elg) .channel(loopResources.onDatagramChannel(elg)); } return ConnectionProvider.newConnection() .acquire(b); } }
/** * Creates TcpClient for target address. * * @param address connect address * @return tcp client */ private TcpClient newTcpClient(Address address) { return TcpClient.create(ConnectionProvider.newConnection()) .runOn(loopResources) .host(address.host()) .port(address.port()) .option(ChannelOption.TCP_NODELAY, true) .option(ChannelOption.SO_KEEPALIVE, true) .option(ChannelOption.SO_REUSEADDR, true) .option(ChannelOption.CONNECT_TIMEOUT_MILLIS, config.getConnectTimeout()) .bootstrap(b -> BootstrapHandlers.updateConfiguration(b, "outbound", channelInitializer)); }
@Test public void tcpClientHandlesLineFeedDataFixedPool() throws InterruptedException { Consumer<? super Connection> channelInit = c -> c .addHandler("codec", new LineBasedFrameDecoder(8 * 1024)); // ConnectionProvider p = ConnectionProvider.fixed // ("tcpClientHandlesLineFeedDataFixedPool", 1); ConnectionProvider p = ConnectionProvider.newConnection(); tcpClientHandlesLineFeedData( TcpClient.create(p) .host("localhost") .port(echoServerPort) .doOnConnected(channelInit) ); }
HttpClient.create(ConnectionProvider.newConnection()) .port(server.port()) .doOnRequest((req, c) -> {
@Test public void testIssue473() throws Exception { SelfSignedCertificate cert = new SelfSignedCertificate(); SslContextBuilder serverSslContextBuilder = SslContextBuilder.forServer(cert.certificate(), cert.privateKey()); DisposableServer server = HttpServer.create() .port(0) .wiretap(true) .secure(spec -> spec.sslContext(serverSslContextBuilder)) .bindNow(); StepVerifier.create( HttpClient.create(ConnectionProvider.newConnection()) .secure() .websocket() .uri("wss://" + server.host() + ":" + server.port()) .handle((in, out) -> Mono.empty())) .expectErrorMatches(t -> t.getCause() instanceof CertificateException) .verify(Duration.ofSeconds(30)); server.disposeNow(); }