-
Notifications
You must be signed in to change notification settings - Fork 1.3k
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
add generic interface for transact/read transact. #11302
base: main
Are you sure you want to change the base?
Conversation
Result of foundationdb-pr-clang-ide on Linux CentOS 7
|
Result of foundationdb-pr-clang on Linux CentOS 7
|
Result of foundationdb-pr-cluster-tests on Linux CentOS 7
|
Result of foundationdb-pr on Linux CentOS 7
|
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.
Thanks for the PR, could you add some test cases and examples in fdb_test.go
for the new methods?
@@ -0,0 +1,116 @@ | |||
/* | |||
* database.go |
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.
* database.go | |
* transact.go |
// FoundationDB Go API | ||
package fdb | ||
|
||
func Transact(db Database, f func(t Transaction) 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.
Maybe a better name would be TransactWithoutReturnValue
?
return err | ||
} | ||
|
||
func Transact1[T any](db Database, f func(t Transaction) (T, error)) (T, 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.
Could you provide some examples in which cases those different Transact1
, Transact2
and Transact3
are needed?
The current
db.Transact
anddb.ReadTransact
relies oninterface{}
and is error prone. This PR provides a new API based around generics forTransact
andReadTransact
.It is intended to be used like:
Any feedback, please let me know. If there is alignment on a solution, then I can add tests, and such.
Code-Reviewer Section
The general pull request guidelines can be found here.
Please check each of the following things and check all boxes before accepting a PR.
For Release-Branches
If this PR is made against a release-branch, please also check the following:
release-branch
ormain
if this is the youngest branch)