Hi guys, I am new and starting out with Coroutines...
# spring
v
Hi guys, I am new and starting out with Coroutines and Spring integration. Now that Spring Boot 2.2 are released, is there a comprehensive example where a basic crud app is using coroutines (I guess probably with R2DBC)? I want to learn how and where to spawn coroutines and know when to use the right context. Thanks
r
I think the best way to use coroutines is with Ktor. But, if you want to use it with Spring, maybe, the you should use it with webFlux. Here an exemple: https://github.com/sdeleuze/spring-boot-coroutines-demo
💯 1
v
thanks, will for sure take a look. I am considering moving to Ktor, but I still need to get more developer buy in. Out of curiosity, is there anything major in Spring, that Ktor can not do?
e
ktor doesn’t have inner DI, so all magic with spring-starters is not possible to do with ktor. You can add DI by youself to ktor, but it’s not be such powerfull as in spring
☝️ 3
r
Well, Spring its a exclente tool, the most used with java. But i don't like it, becouse have a lot of "magic" behind it, with all annotations. I use it when the customers ask. Otherwised i prefer Ktor. I think all the things that Spring does, Ktor can also do, but with different implementation.
e
In a spring it’s possible to add one starter with some db, and it checks, whatever you have already configure DB connection, or not, and if you have it, starter will use this connection (and ever more of this, in starter possible to check if class exists and make add configuration depend on it). In ktor you need to do all this by yourself. This is just one of simplest example. I like ktor, it’s very good designed library, and well suited for many projects. But for big project Spring is still more preferred.
r
Your can also find an exemple here: https://github.com/razvn/webflux-r2dbc-kotlin
💯 1