extension-reactor
extension-reactor copied to clipboard
Create an optional Kotlin module
The new Spring reactive way is Reactor + Kotlin Coroutines (with suspend functions). This allows for sequential composition of functions working on reactive streams.
I would suggest to create an additional Kotlin module, which allows for usage of reified types in query and command gateways and allow for usage of suspend functions instead of chains of flatMap calls on Mono and Flux.
Let us synchronize with extension-kotlin which part goes where.
Just to understand your stance on the matter @zambrovski, you mean an extension which basis itself on both the reactor and kotlin extension, adding additional features for this combination?
Not necessary. I think inside of the Kotlin Module there should be a JAR for reactive extensions.
I believe Kotlin extension should go for coroutines by default, but if you want to use it with Reactor, the reactive extension can be just leveraged.
Using Kotlin reified classes you can skip the specification of the classes every time... I’ll share some code on that...
Gotcha, thanks for specifying further @zambrovski.
I agree with @zambrovski that extension-kotlin would ideally provide coroutine-based implementations of gateways, similar to how extension-reactor provides publisher-based implementations, and vanilla axon provides future-based implementations. The callback pattern used here is not one I've seen used in server-side code.
That said, I do not think it is high priority. extension-reactor is perfect for working with Spring WebFlux. I have not found coroutine support to be stellar across the ecosystem, and to my knowledge they are not supported at all by spring-security authorization annotations. JetBrains provides first-party support for interacting with publishers here and here. These work seamlessly with extension-reactor, allowing you to write suspending wrappers with syntax that you prefer. I also enjoy how easy and obvious it is to explicitly await or not await a result, which is one of my primary critiques with the suspend syntax.
There are many places throughout the Axon framework where reified types would be helpful. Gateways, repositories, fixtures, you could have an entire extension module of just reified wrapper functions. 😆