Hi! I was thinking about replacing spring complete...
# announcements
t
Hi! I was thinking about replacing spring completely with ktor and other tools. As most things seem to be more or less easily replaceable i wasa wondering how to manage transactions in such a case. How do other people address this issue? While there are plenty examples of how to do programmatic transactions with r2dbc or exposed they all are very simplistic and only show how to use it in the data access layer. but of course we actually need to handle it on service layer so the transaction spans over multiple db queries. What tools are there to abstract the transaction handling?
👀 1
r
My personal preference: Open the transaction at the start of the request. Wire everything together for that request, injecting the transaction as required. Run the request. Close / roll back the transaction as required in the same method up at the top of the stack that you opened it. Basically this makes it a request scoped bean (in Spring language), it’s just that instead of wiring the app together once at the start of the app, and then making the transaction available via a horrible proxy / thread local mechanism, you just wire the app together per request.
t
yeah sure. but i fear there is a bunch of boilerplate and infrastructure code to write. What about connection pooling? How to make sure only one connection is used throughout the handling of the request? and of course the transaction handling itself
any other thoughts on this? :D
k
hi, there is a channel named #C0A974TJ9
t
i dont think this is strictly a ktor topic, but maybe #C0B8RC352 is a good channel
👍 1
i'll post the question there