Skip to content

Commit 52bf345

Browse files
committed
Added isSecured configuration setting in TransportConfig; cleaned javadocs
1 parent 5036381 commit 52bf345

File tree

2 files changed

+27
-25
lines changed

2 files changed

+27
-25
lines changed

transport-parent/transport-netty/src/main/java/io/scalecube/transport/netty/tcp/TcpSender.java

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@
1010
import reactor.netty.Connection;
1111
import reactor.netty.channel.BootstrapHandlers;
1212
import reactor.netty.resources.ConnectionProvider;
13-
import reactor.netty.tcp.SslProvider;
1413
import reactor.netty.tcp.TcpClient;
1514

1615
final class TcpSender implements Sender {
@@ -42,18 +41,19 @@ public Mono<Void> send(Message message) {
4241
}
4342

4443
private TcpClient newTcpClient(SenderContext context, Address address) {
45-
return TcpClient.create(ConnectionProvider.newConnection())
46-
.runOn(context.loopResources())
47-
.host(address.host())
48-
.port(address.port())
49-
.option(ChannelOption.TCP_NODELAY, true)
50-
.option(ChannelOption.SO_KEEPALIVE, true)
51-
.option(ChannelOption.SO_REUSEADDR, true)
52-
.option(ChannelOption.CONNECT_TIMEOUT_MILLIS, config.connectTimeout())
53-
.secure(config.isSecured() ? SslProvider.defaultClientProvider() : null)
54-
.bootstrap(
55-
b ->
56-
BootstrapHandlers.updateConfiguration(
57-
b, "outbound", new TcpChannelInitializer(config.maxFrameLength())));
44+
TcpClient tcpClient =
45+
TcpClient.create(ConnectionProvider.newConnection())
46+
.runOn(context.loopResources())
47+
.host(address.host())
48+
.port(address.port())
49+
.option(ChannelOption.TCP_NODELAY, true)
50+
.option(ChannelOption.SO_KEEPALIVE, true)
51+
.option(ChannelOption.SO_REUSEADDR, true)
52+
.option(ChannelOption.CONNECT_TIMEOUT_MILLIS, config.connectTimeout())
53+
.bootstrap(
54+
b ->
55+
BootstrapHandlers.updateConfiguration(
56+
b, "outbound", new TcpChannelInitializer(config.maxFrameLength())));
57+
return config.isSecured() ? tcpClient.secure() : tcpClient;
5858
}
5959
}

transport-parent/transport-netty/src/main/java/io/scalecube/transport/netty/websocket/WebsocketSender.java

Lines changed: 13 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
import reactor.netty.Connection;
1212
import reactor.netty.http.client.HttpClient;
1313
import reactor.netty.http.client.WebsocketClientSpec;
14-
import reactor.netty.tcp.SslProvider;
14+
import reactor.netty.tcp.TcpClient;
1515

1616
final class WebsocketSender implements Sender {
1717

@@ -48,16 +48,18 @@ public Mono<Void> send(Message message) {
4848
private HttpClient.WebsocketSender newWebsocketSender(SenderContext context, Address address) {
4949
return HttpClient.newConnection()
5050
.tcpConfiguration(
51-
tcpClient ->
52-
tcpClient
53-
.runOn(context.loopResources())
54-
.host(address.host())
55-
.port(address.port())
56-
.option(ChannelOption.TCP_NODELAY, true)
57-
.option(ChannelOption.SO_KEEPALIVE, true)
58-
.option(ChannelOption.SO_REUSEADDR, true)
59-
.option(ChannelOption.CONNECT_TIMEOUT_MILLIS, config.connectTimeout())
60-
.secure(config.isSecured() ? SslProvider.defaultClientProvider() : null))
51+
tcpClient -> {
52+
TcpClient tcpClient1 =
53+
tcpClient
54+
.runOn(context.loopResources())
55+
.host(address.host())
56+
.port(address.port())
57+
.option(ChannelOption.TCP_NODELAY, true)
58+
.option(ChannelOption.SO_KEEPALIVE, true)
59+
.option(ChannelOption.SO_REUSEADDR, true)
60+
.option(ChannelOption.CONNECT_TIMEOUT_MILLIS, config.connectTimeout());
61+
return config.isSecured() ? tcpClient1.secure() : tcpClient1;
62+
})
6163
.websocket(
6264
WebsocketClientSpec.builder().maxFramePayloadLength(config.maxFrameLength()).build());
6365
}

0 commit comments

Comments
 (0)