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

POC: Use transaction manager instead of Reader/Writer #5525

Draft
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

johanbrandhorst
Copy link
Collaborator

@johanbrandhorst johanbrandhorst commented Feb 7, 2025

This is a proof-of-concept of a refactor to the db.Reader/db.Writer interface we use across the project to manage access to the database. The primary goal is to make it much harder to accidentally use nested DB connections. A secondary goal is to pave the way for distinguishing between read and write operations such that in the future it could be easier to support read replica databases.

The first commit adds the TransactionManager interface, which exposes functions for creating transactions and single read and write operations. The separation between DoRoTx and DoRwTx is so that we could implement read replica logic without having to do the work to separate these out logically at a later time.

The second commit switches the alias repository to using the TransactionManager instead of the db.Reader and db.Writer directly.

The TransactionManager serves as the entrypoint
to the Database, allowing the user to create new transactions
or single reader or writer operations.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant