-
Notifications
You must be signed in to change notification settings - Fork 128
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
SQL Database Interfaces Definition #2659
SQL Database Interfaces Definition #2659
Conversation
Codecov ReportPatch and project coverage have no change.
Additional details and impacted files@@ Coverage Diff @@
## master #2659 +/- ##
=======================================
Coverage 16.21% 16.21%
=======================================
Files 160 160
Lines 12559 12559
Branches 487 487
=======================================
Hits 2037 2037
Misses 10353 10353
Partials 169 169
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. |
Just did a glance, it looks good to me. Can you fix the lint issues? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think this looks great! I added a few comments that you can consider in another PR since this is already merged. Let me know what you think!
|
||
// BeginTxFunc starts a transaction and executes the given function within the transaction. | ||
// It the function runs successfully, BeginTxFunc commits the transaction, otherwise it rolls back and return an error. | ||
BeginTxFunc(context.Context, DatabaseTxOptions, func(DatabaseTx) error) error |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is this necessary ? BeginTxFunc
is no longer supported in pgx/v5
. see jackc/pgx#1169 (comment) .
This won't make the interface compatible with pgx/v5
. I think we should remove it.
BeginTx(context.Context, DatabaseTxOptions) (DatabaseTx, error) | ||
|
||
// BeginTxFunc starts a transaction and executes the given function within the transaction. It the function runs successfully, BeginTxFunc commits the transaction, otherwise it rolls back and return an errorr. | ||
BeginTxFunc(context.Context, DatabaseTxOptions, func(DatabaseTx) error) error |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same
|
||
// Scan reads the values from the current row into dest values positionally. It returns an error if any occurred during the read operation. | ||
Scan(dest ...any) error | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think we should add another interface that acts as a generic placeholder for both DatabasePool
and DatabaseConn
. In various parts of the armada, such as here , the Querier
interface is a placeholder for both pgxpool.Pool
pgx.Conn
. It is a loose interface that requires only 3 functions https://pkg.go.dev/github.com/jackc/pgtype@v1.13.0/pgxtype#Querier
You can introduce a new similar one here for DatabasePool
and DatabaseConn
that requires maybe only Exec
and Query
.
What type of PR is this?
This PR introduces the definition of interfaces proposed in this design https://github.com/armadaproject/armada/blob/master/docs/design/database_interfaces.md
What this PR does / why we need it:
Those interfaces are meant to establish an abstraction over the existing Postgres implementation which will eventually lead to removing the tight coupling between Armada and Postgres.
Special notes for your reviewer:
This is a follow PR to #2624, and it's meant particularly to introduce the interfaces that were proposed in the design. Follow PRs will be raised regarding the implementation of the interfaces as well as integrating those implementations with Armada.
┆Issue is synchronized with this Jira Task by Unito