boundary icon indicating copy to clipboard operation
boundary copied to clipboard

POC: Use transaction manager instead of Reader/Writer

Open johanbrandhorst opened this issue 9 months ago • 0 comments
trafficstars

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.

johanbrandhorst avatar Feb 07 '25 18:02 johanbrandhorst