I guess this has been asked before but I'm at a bit of a loose end. I'm adding transaction support to my ktor application and currently have an implementation that works like this:
Copy code
// All db calls in this block will be executed within a transaction, on a connection held in the coroutine context
transactional {
...
}
As it stands it requires a call to a static method on application startup to initialise a tx manager which the
transactional
call then uses to execute the tx. This is hard to test. I'd instead like to inject a transaction manager into a parent coroutine context so it's available everywhere in the app without needing to initialise it via a static method. I looked at using a feature that intercepts the application pipeline to do this but I don't think it does what I need. Any ideas?