Code Review
/
nonrtric.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
review
|
tree
raw
|
inline
| side by side
ECS, deleting jobs when the type is deleted
[nonrtric.git]
/
enrichment-coordinator-service
/
src
/
main
/
java
/
org
/
oransc
/
enrichment
/
clients
/
AsyncRestClient.java
diff --git
a/enrichment-coordinator-service/src/main/java/org/oransc/enrichment/clients/AsyncRestClient.java
b/enrichment-coordinator-service/src/main/java/org/oransc/enrichment/clients/AsyncRestClient.java
index
f0f6c4b
..
1b8e064
100644
(file)
--- a/
enrichment-coordinator-service/src/main/java/org/oransc/enrichment/clients/AsyncRestClient.java
+++ b/
enrichment-coordinator-service/src/main/java/org/oransc/enrichment/clients/AsyncRestClient.java
@@
-42,9
+42,7
@@
import org.springframework.web.reactive.function.client.WebClientResponseExcepti
import reactor.core.publisher.Mono;
import reactor.netty.http.client.HttpClient;
import reactor.core.publisher.Mono;
import reactor.netty.http.client.HttpClient;
-import reactor.netty.resources.ConnectionProvider;
-import reactor.netty.tcp.ProxyProvider.Proxy;
-import reactor.netty.tcp.TcpClient;
+import reactor.netty.transport.ProxyProvider;
/**
* Generic reactive REST client.
/**
* Generic reactive REST client.
@@
-200,32
+198,32
@@
public class AsyncRestClient {
&& !httpProxyConfig.httpProxyHost().isEmpty();
}
&& !httpProxyConfig.httpProxyHost().isEmpty();
}
- private
TcpClient createTc
pClient() {
-
TcpClient client = TcpClient.create(ConnectionProvider.newConnection()
) //
+ private
HttpClient buildHtt
pClient() {
+
HttpClient httpClient = HttpClient.create(
) //
.option(ChannelOption.CONNECT_TIMEOUT_MILLIS, 10_000) //
.doOnConnected(connection -> {
connection.addHandlerLast(new ReadTimeoutHandler(30));
connection.addHandlerLast(new WriteTimeoutHandler(30));
});
.option(ChannelOption.CONNECT_TIMEOUT_MILLIS, 10_000) //
.doOnConnected(connection -> {
connection.addHandlerLast(new ReadTimeoutHandler(30));
connection.addHandlerLast(new WriteTimeoutHandler(30));
});
+
if (this.sslContext != null) {
if (this.sslContext != null) {
-
client = client.secure(c -> c
.sslContext(sslContext));
+
httpClient = httpClient.secure(ssl -> ssl
.sslContext(sslContext));
}
}
+
if (isHttpProxyConfigured()) {
if (isHttpProxyConfigured()) {
-
client = client.proxy(proxy -> proxy.type(Proxy.HTTP).host(httpProxyConfig.httpProxyHost()
)
- .port(httpProxyConfig.httpProxyPort()));
+
httpClient = httpClient.proxy(proxy -> proxy.type(ProxyProvider.Proxy.HTTP
)
+ .
host(httpProxyConfig.httpProxyHost()).
port(httpProxyConfig.httpProxyPort()));
}
}
- return
c
lient;
+ return
httpC
lient;
}
}
- private WebClient createWebClient(String baseUrl, TcpClient tcpClient) {
- HttpClient httpClient = HttpClient.from(tcpClient);
-
- ReactorClientHttpConnector connector = new ReactorClientHttpConnector(httpClient);
+ private WebClient buildWebClient(String baseUrl) {
+ final HttpClient httpClient = buildHttpClient();
ExchangeStrategies exchangeStrategies = ExchangeStrategies.builder() //
.codecs(configurer -> configurer.defaultCodecs().maxInMemorySize(-1)) //
.build();
return WebClient.builder() //
ExchangeStrategies exchangeStrategies = ExchangeStrategies.builder() //
.codecs(configurer -> configurer.defaultCodecs().maxInMemorySize(-1)) //
.build();
return WebClient.builder() //
- .clientConnector(
connector
) //
+ .clientConnector(
new ReactorClientHttpConnector(httpClient)
) //
.baseUrl(baseUrl) //
.exchangeStrategies(exchangeStrategies) //
.build();
.baseUrl(baseUrl) //
.exchangeStrategies(exchangeStrategies) //
.build();
@@
-233,15
+231,9
@@
public class AsyncRestClient {
private Mono<WebClient> getWebClient() {
if (this.webClient == null) {
private Mono<WebClient> getWebClient() {
if (this.webClient == null) {
- try {
- TcpClient tcpClient = createTcpClient();
- this.webClient = createWebClient(this.baseUrl, tcpClient);
- } catch (Exception e) {
- logger.error("Could not create WebClient {}", e.getMessage());
- return Mono.error(e);
- }
+ this.webClient = buildWebClient(baseUrl);
}
}
- return Mono.just(
this.webClient
);
+ return Mono.just(
buildWebClient(baseUrl)
);
}
}
}
}