Skip to content

Commit

Permalink
All: Align clients timeout
Browse files Browse the repository at this point in the history
  • Loading branch information
bitxon committed Sep 6, 2023
1 parent 2034361 commit 6de3e00
Show file tree
Hide file tree
Showing 5 changed files with 15 additions and 6 deletions.
1 change: 1 addition & 0 deletions dropwizard-app/src/main/resources/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ database:

exchangeClientConfig:
basePath: 'http://localhost:8888/exchanges?currency='
timeout: 5s # default=0.5s

logging:
level: INFO
Expand Down
2 changes: 1 addition & 1 deletion micronaut-app/src/main/resources/application.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ micronaut:
services:
exchange-client:
url: "http://localhost:8888"
read-timeout: 1m
read-timeout: 5s # default=10s
endpoints:
all:
port: 8081
Expand Down
2 changes: 2 additions & 0 deletions quarkus-app/src/main/resources/application.properties
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@ quarkus.datasource.jdbc.url = jdbc:postgresql://localhost:5432/postgres
quarkus.hibernate-orm.database.generation = drop-and-create

quarkus.rest-client.exchange-client.url=http://localhost:8888
# Default '30000'
quarkus.rest-client.exchange-client.read-timeout=5000
quarkus.rest-client.exchange-client.scope=jakarta.inject.Singleton

# https://quarkus.io/guides/cdi-reference#bean_discovery
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,14 +7,19 @@
import org.springframework.web.reactive.function.client.support.WebClientAdapter;
import org.springframework.web.service.invoker.HttpServiceProxyFactory;

import java.time.Duration;

@Configuration
public class ExchangeClientConfig {

@Bean
public ExchangeClient exchangeClient(@Value("${http.exchange-client.url}") String url) {
var webClient = WebClient.create(url);
var factory = HttpServiceProxyFactory.builder(WebClientAdapter.forClient(webClient)).build();
var serviceClient = factory.createClient(ExchangeClient.class);
return serviceClient;
public ExchangeClient exchangeClient(@Value("${http.exchange-client.url}") String url,
@Value("${http.exchange-client.block-timeout}") Duration blockTimeout,
WebClient.Builder webClientBuilder) {
var webClient = webClientBuilder.baseUrl(url).build();
var factory = HttpServiceProxyFactory.builder(WebClientAdapter.forClient(webClient))
.blockTimeout(blockTimeout)
.build();
return factory.createClient(ExchangeClient.class);
}
}
1 change: 1 addition & 0 deletions spring-app/src/main/resources/application.yml
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ spring:
http:
exchange-client:
url: http://localhost:8888
block-timeout: 5s # default=5s

logging:
level:
Expand Down

0 comments on commit 6de3e00

Please sign in to comment.