Introduces DbContext to allow migration to Doobie-RC4 #48
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
See #47 for issue and discussion. I've introduced a
DbContext
parameter when creating theDatabase
layer, allowing to define aLogHandler
for Doobie.I could have passed the
DbContext
on every call totransaction
orautoCommit
, but I chose to define it at the layer level. Two main reasons:From a usage perspective, it seems more practical to me to define the log-level of your DB layer when defining said layer, instead of defining it every singe time you run the transaction. Sure, this limits a little bit your options, as you cannot customize the
LogHandler
on everytransaction
call, but you can handle that by having multipleDatabase
layers (with different logging levels) and using the one you want.From a long-term perspective: my current implementation for Doobie can be improved. I'm recreating a
Transactor
every single time a transaction is run, passing it a single JDBC connection instead of a connections source. This allow me to easily control the transaction from the outside, but it might have performance implications. In the future, I'd like to have a single Transactor for the database layer, where I can control which connection it gets by manipulating the source instead. This would not be compatible with passing a LogHandler on each call totransaction
.