apple / foundationdb

FoundationDB - the open source, distributed, transactional key-value store
https://apple.github.io/foundationdb/
Apache License 2.0
14.42k stars 1.31k forks source link

add generic interface for transact/read transact. #11302

Open newhook opened 5 months ago

newhook commented 5 months ago

The current db.Transact and db.ReadTransact relies on interface{} and is error prone. This PR provides a new API based around generics for Transact and ReadTransact.

It is intended to be used like:

err = fdb.Transact(db, func(t fdb.Transaction) error {
    ...
})

val, err = fdb.Transact1(db, func(t fdb.Transaction) (string, error) {
    ...
})

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:

foundationdb-ci commented 5 months ago

Result of foundationdb-pr-clang-ide on Linux CentOS 7

foundationdb-ci commented 5 months ago

Result of foundationdb-pr-clang on Linux CentOS 7

foundationdb-ci commented 5 months ago

Result of foundationdb-pr-cluster-tests on Linux CentOS 7

foundationdb-ci commented 5 months ago

Result of foundationdb-pr on Linux CentOS 7