-
Notifications
You must be signed in to change notification settings - Fork 41.6k
Description
Problem
The current design of spring.http.reactiveclient and spring.http.client introduces unnecessary duplication and complexity.
These two configurations serve blocking clients (RestClient) and reactive clients (WebClient) respectively.
Their configuration options are nearly identical, with the only difference being the underlying implementations (factory vs connector).
spring:
http:
client:
connect-timeout: 1s
read-timeout: 10s
factory: jdk
service:
group:
service-a:
base-url: service-a:8080
connect-timeout: 2s
read-timeout: 30s
reactiveclient:
connect-timeout: 1s
read-timeout: 10s
connector: jdk
service:
group:
service-b:
base-url: service-b:8080
connect-timeout: 2s
read-timeout: 30sThis configuration structure is unnecessarily verbose and difficult to reason about. We can unify spring.http.reactiveclient and spring.http.client into a single spring.http.client configuration.
Proposed Solution
spring:
http:
client:
connect-timeout: 1s
read-timeout: 10s
service:
group:
service-a:
base-url: service-a:8080
connect-timeout: 2s
read-timeout: 30s
client-type: rest_client
service-b:
base-url: service-b:8080
connect-timeout: 2s
read-timeout: 30s
client-type: web_clientFrom a user's perspective, this unified configuration is clearer. The trade-off is that we cannot provide factory/connector configuration in properties, which is acceptable compared to the benefit of clearer configuration. Users can easily provide customization through RestClientCustomizer/WebClientCustomizer beans, making this a worthwhile trade-off.
In terms of implementation, we can merge the spring-boot-restclient and spring-boot-webclient modules into spring-boot-http-client, while keeping the spring-boot-starter-restclient and spring-boot-starter-webclient starters.
Overall, we unify the configuration for blocking and reactive clients, sacrificing the ability to configure factory/connector in exchange for more consistent and ergonomic configuration and cleaner code implementation.