Jacob K

02/28/2023, 6:56 AM
I'm using the the mongodb reactive driver in a project with a lot of coroutines/suspending stuff. I was thinking it might be nice to wrap the session/transaction handling in some kind of coroutine context that can both ensure rollback etc in case of cancellations/error and possibly provide the current session to the code using the client directly. Does this seem like a sensible idea and does anyone have any examples of similar solutions?
For example, does it make sense to store the session (needed for mongodb tranasactions) in the coroutine context and then access the it using
and conditionally add the session reference to the mongo client call if present? (not sure how idiomatic it is to access the current context from arbitrary code)