Closed pull-vert closed 3 years ago
I think I would like to keep consistency between regular Spring and Spring Fu concepts, and reactive bits can be used in regular/blocking apps (WebClient
for example but there are other use cases), that's why I am not in favor of this proposal to introduce such distinction at configuration API level.
I even don't like the distinction we do at application level but it is due to historical choices made on Spring Framework that forces Spring Boot to have distinct application contexts.
That's exactly this distinction in application context that gave me the idea to push it further in this proposal ;)
I understand your opinion, writing this proposal was a fun and interesting exercise for me. You can close it if you want, no regret :)
Thanks for your understanding.
Reactive apps must never block, and blocking apps should not use reactive libraries. They are kind of two incompatible worlds.
This Github issue is a proposal on this subject, and is the continuation of PR-333 discussion
Current implementation
For now spring-fu expose all DSLs with no limitation using a common
ConfigurationDsl
which all DSLs are based on.This implies that all configurations are allowed today, for example this one :
This limitation also forces non compatible DSLs (both based on
ConfigurationDsl
) to have distinct names, for examplewebFlux
andwebMvc
.Proposal
The goal of this proposal is to force the user to choose a mode between Blocking and Reactive. No blocking DSL would then be available inside a spring-fu reactive App configuration, and vice-versa.
Reactive example with this proposal
Blocking example with this proposal
Implementation of this proposal
Change the existing
reactiveWebApplication
DSL to define a newReactiveApplicationDsl
scope, instead of theApplicationDsl
that is currently used by both reactive and blocking apps.This
ReactiveApplicationDsl
would extend a newReactiveConfigurationDsl
. This change would also require to add newreactiveApplication
andreactiveConfiguration
DSLs for non web apps and sub-configurations :With these changes the
ReactiveConfigurationDsl.security { }
would be the Reactive version, and theConfigurationDsl.security { }
would be the MVC one.As mentionned before, it would also allow to have just
web
instead of bothwebFlux
andwebMVC
, exposer2dbc
only for reactive apps, and maybe more but these would be breaking changes for the current API.Extra implementation note Current
ConfigurationDsl
would have to be renamed toAbstractConfigurationDsl
and would have 2 distinct implementations :ConfigurationDsl
andReactiveConfigurationDsl
.For a smooth transition, existing DSLs could continue to be extensions on
AbstractConfigurationDsl
to ensure backward compatibility, with a deprecation notice to suggest to use new exclusive DSLs.