Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Introduces DbContext to allow migration to Doobie-RC4 #48

Merged
merged 5 commits into from
Aug 5, 2023

Conversation

gaelrenoux
Copy link
Owner

See #47 for issue and discussion. I've introduced a DbContext parameter when creating the Database layer, allowing to define a LogHandler for Doobie.

I could have passed the DbContext on every call to transaction or autoCommit, but I chose to define it at the layer level. Two main reasons:

  1. 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 every transaction call, but you can handle that by having multiple Database layers (with different logging levels) and using the one you want.

  2. 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 to transaction.

@gaelrenoux gaelrenoux added the enhancement New feature or request label Jul 29, 2023
@gaelrenoux gaelrenoux added this to the 5.0.0 milestone Jul 29, 2023
@gaelrenoux gaelrenoux self-assigned this Jul 29, 2023
@gaelrenoux gaelrenoux merged commit 112d9ec into master Aug 5, 2023
1 check passed
@gaelrenoux gaelrenoux deleted the Doobie-RC4-context branch August 5, 2023 14:36
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

1 participant