Skip to content

Commit 19bd016

Browse files
committed
Added isSecured option to the RSocketClientTransportFactory
1 parent 81caedb commit 19bd016

File tree

1 file changed

+44
-14
lines changed

1 file changed

+44
-14
lines changed

services-transport-parent/services-transport-rsocket/src/main/java/io/scalecube/services/transport/rsocket/RSocketClientTransportFactory.java

Lines changed: 44 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -19,14 +19,30 @@ public interface RSocketClientTransportFactory {
1919
* @return factory function for {@link RSocketClientTransportFactory}
2020
*/
2121
static Function<LoopResources, RSocketClientTransportFactory> tcp() {
22+
return tcp(false);
23+
}
24+
25+
/**
26+
* Returns default rsocket tcp client transport factory.
27+
*
28+
* @see TcpClientTransport
29+
* @param isSecured is client transport secured
30+
* @return factory function for {@link RSocketClientTransportFactory}
31+
*/
32+
static Function<LoopResources, RSocketClientTransportFactory> tcp(boolean isSecured) {
2233
return (LoopResources loopResources) ->
2334
(RSocketClientTransportFactory)
24-
address ->
25-
TcpClientTransport.create(
26-
TcpClient.newConnection()
27-
.host(address.host())
28-
.port(address.port())
29-
.runOn(loopResources));
35+
address -> {
36+
TcpClient tcpClient =
37+
TcpClient.newConnection()
38+
.runOn(loopResources)
39+
.host(address.host())
40+
.port(address.port())
41+
.option(ChannelOption.TCP_NODELAY, true)
42+
.option(ChannelOption.SO_KEEPALIVE, true)
43+
.option(ChannelOption.SO_REUSEADDR, true);
44+
return TcpClientTransport.create(isSecured ? tcpClient.secure() : tcpClient);
45+
};
3046
}
3147

3248
/**
@@ -36,20 +52,34 @@ static Function<LoopResources, RSocketClientTransportFactory> tcp() {
3652
* @return factory function for {@link RSocketClientTransportFactory}
3753
*/
3854
static Function<LoopResources, RSocketClientTransportFactory> websocket() {
55+
return websocket(false);
56+
}
57+
58+
/**
59+
* Returns default rsocket websocket client transport factory.
60+
*
61+
* @see WebsocketClientTransport
62+
* @param isSecured is client transport secured
63+
* @return factory function for {@link RSocketClientTransportFactory}
64+
*/
65+
static Function<LoopResources, RSocketClientTransportFactory> websocket(boolean isSecured) {
3966
return (LoopResources loopResources) ->
4067
(RSocketClientTransportFactory)
4168
address ->
4269
WebsocketClientTransport.create(
4370
HttpClient.newConnection()
4471
.tcpConfiguration(
45-
tcpClient ->
46-
tcpClient
47-
.runOn(loopResources)
48-
.host(address.host())
49-
.port(address.port())
50-
.option(ChannelOption.TCP_NODELAY, true)
51-
.option(ChannelOption.SO_KEEPALIVE, true)
52-
.option(ChannelOption.SO_REUSEADDR, true)),
72+
tcpClient -> {
73+
TcpClient tcpClient1 =
74+
tcpClient
75+
.runOn(loopResources)
76+
.host(address.host())
77+
.port(address.port())
78+
.option(ChannelOption.TCP_NODELAY, true)
79+
.option(ChannelOption.SO_KEEPALIVE, true)
80+
.option(ChannelOption.SO_REUSEADDR, true);
81+
return isSecured ? tcpClient1.secure() : tcpClient1;
82+
}),
5383
"/");
5484
}
5585

0 commit comments

Comments
 (0)