Skip to content

Commit

Permalink
Merge pull request #90 from aws-containers/ui-http-keepalive
Browse files Browse the repository at this point in the history
feat: Setting to control ui service keep alives
  • Loading branch information
niallthomson authored Dec 12, 2022
2 parents 17b9294 + 1f31748 commit d5fa851
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -65,12 +65,16 @@ public class Clients {
@Value("${endpoints.logging}")
private boolean logging;

@Value("${endpoints.http.keep-alive}")
private boolean keepAlive;

private WebClient createWebClient(ObjectMapper mapper, WebClient.Builder webClientBuilder) {
TcpClient tcpClient = TcpClient.create()
.option(ChannelOption.CONNECT_TIMEOUT_MILLIS, 1000) // Connection Timeout
.doOnConnected(connection ->
connection.addHandlerLast(new ReadTimeoutHandler(10)) // Read Timeout
.addHandlerLast(new WriteTimeoutHandler(10))); // Write Timeout

ExchangeStrategies strategies = ExchangeStrategies
.builder()
.codecs(clientDefaultCodecsConfigurer -> {
Expand All @@ -79,7 +83,7 @@ private WebClient createWebClient(ObjectMapper mapper, WebClient.Builder webClie
}).build();

return webClientBuilder
.clientConnector(new ReactorClientHttpConnector(HttpClient.from(tcpClient)))
.clientConnector(new ReactorClientHttpConnector(HttpClient.from(tcpClient).keepAlive(keepAlive)))
.exchangeStrategies(strategies)
.filters( exchangeFilterFunctions -> {
if(logging) {
Expand Down
4 changes: 2 additions & 2 deletions src/ui/src/main/resources/application.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,15 +10,15 @@ endpoints:
assets: false #http://localhost:8084
checkout: false #http://localhost:8085
logging: false
http:
keep-alive: true

retail:
ui:
metadata:
region: "none"
banner: ""



management:
endpoints:
web:
Expand Down

0 comments on commit d5fa851

Please sign in to comment.