Skip to content

Commit 4520fb4

Browse files
committed
Renaming of TransportConfig property, fixed childOptions settings at server sides
1 parent 4427a68 commit 4520fb4

File tree

5 files changed

+32
-36
lines changed

5 files changed

+32
-36
lines changed

transport-parent/transport-api/src/main/java/io/scalecube/cluster/transport/api/TransportConfig.java

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ public final class TransportConfig implements Cloneable {
1515
public static final int DEFAULT_LOCAL_CONNECT_TIMEOUT = 1_000;
1616

1717
private int port = 0;
18-
private boolean isSecured = false; // is client secured
18+
private boolean clientSecured = false; // client secured flag
1919
private int connectTimeout = DEFAULT_CONNECT_TIMEOUT;
2020
private MessageCodec messageCodec = MessageCodec.INSTANCE;
2121
private int maxFrameLength = 2 * 1024 * 1024; // 2 MB
@@ -70,19 +70,19 @@ public TransportConfig port(int port) {
7070
return t;
7171
}
7272

73-
public boolean isSecured() {
74-
return isSecured;
73+
public boolean isClientSecured() {
74+
return clientSecured;
7575
}
7676

7777
/**
7878
* Setter to denote whether client part of the transport is secured.
7979
*
80-
* @param isSecured isSecured
80+
* @param clientSecured clientSecured
8181
* @return new {@code TransportConfig} instance
8282
*/
83-
public TransportConfig secured(boolean isSecured) {
83+
public TransportConfig clientSecured(boolean clientSecured) {
8484
TransportConfig t = clone();
85-
t.isSecured = isSecured;
85+
t.clientSecured = clientSecured;
8686
return t;
8787
}
8888

@@ -163,7 +163,7 @@ public TransportConfig clone() {
163163
public String toString() {
164164
return new StringJoiner(", ", TransportConfig.class.getSimpleName() + "[", "]")
165165
.add("port=" + port)
166-
.add("isSecured=" + isSecured)
166+
.add("clientSecured=" + clientSecured)
167167
.add("connectTimeout=" + connectTimeout)
168168
.add("messageCodec=" + messageCodec)
169169
.add("maxFrameLength=" + maxFrameLength)

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

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -38,9 +38,9 @@ private TcpServer newTcpServer(ReceiverContext context) {
3838
return TcpServer.create()
3939
.runOn(context.loopResources())
4040
.bindAddress(() -> new InetSocketAddress(config.port()))
41-
.option(ChannelOption.TCP_NODELAY, true)
42-
.option(ChannelOption.SO_KEEPALIVE, true)
43-
.option(ChannelOption.SO_REUSEADDR, true)
41+
.childOption(ChannelOption.TCP_NODELAY, true)
42+
.childOption(ChannelOption.SO_KEEPALIVE, true)
43+
.childOption(ChannelOption.SO_REUSEADDR, true)
4444
.doOnChannelInit(
4545
(connectionObserver, channel, remoteAddress) -> {
4646
new TcpChannelInitializer(config.maxFrameLength())

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,6 @@ private TcpClient newTcpClient(SenderContext context, Address address) {
5353
(connectionObserver, channel, remoteAddress) ->
5454
new TcpChannelInitializer(config.maxFrameLength())
5555
.accept(connectionObserver, channel));
56-
return config.isSecured() ? tcpClient.secure() : tcpClient;
56+
return config.isClientSecured() ? tcpClient.secure() : tcpClient;
5757
}
5858
}

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

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -35,14 +35,11 @@ public Mono<DisposableServer> bind() {
3535

3636
private HttpServer newHttpServer(ReceiverContext context) {
3737
return HttpServer.create()
38-
.tcpConfiguration(
39-
tcpServer ->
40-
tcpServer
41-
.runOn(context.loopResources())
42-
.bindAddress(() -> new InetSocketAddress(config.port()))
43-
.option(ChannelOption.TCP_NODELAY, true)
44-
.option(ChannelOption.SO_KEEPALIVE, true)
45-
.option(ChannelOption.SO_REUSEADDR, true));
38+
.runOn(context.loopResources())
39+
.bindAddress(() -> new InetSocketAddress(config.port()))
40+
.childOption(ChannelOption.TCP_NODELAY, true)
41+
.childOption(ChannelOption.SO_KEEPALIVE, true)
42+
.childOption(ChannelOption.SO_REUSEADDR, true);
4643
}
4744

4845
private Mono<Void> onMessage(

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

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

1615
final class WebsocketSender implements Sender {
1716

@@ -46,21 +45,21 @@ public Mono<Void> send(Message message) {
4645
}
4746

4847
private HttpClient.WebsocketSender newWebsocketSender(SenderContext context, Address address) {
49-
return HttpClient.newConnection()
50-
.tcpConfiguration(
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-
})
63-
.websocket(
64-
WebsocketClientSpec.builder().maxFramePayloadLength(config.maxFrameLength()).build());
48+
HttpClient httpClient =
49+
HttpClient.newConnection()
50+
.runOn(context.loopResources())
51+
.host(address.host())
52+
.port(address.port())
53+
.option(ChannelOption.TCP_NODELAY, true)
54+
.option(ChannelOption.SO_KEEPALIVE, true)
55+
.option(ChannelOption.SO_REUSEADDR, true)
56+
.option(ChannelOption.CONNECT_TIMEOUT_MILLIS, config.connectTimeout());
57+
58+
if (config.isClientSecured()) {
59+
httpClient = httpClient.secure();
60+
}
61+
62+
return httpClient.websocket(
63+
WebsocketClientSpec.builder().maxFramePayloadLength(config.maxFrameLength()).build());
6564
}
6665
}

0 commit comments

Comments
 (0)