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鈥檒l occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add multi version support example #133

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

Conversation

alexandrebrg
Copy link

Hi 馃憢

This PR brings an example of usage for the multi_version feature of FoundationDB library client. Moreover, I added a small error handling when defining the client API version to use. It will help to better understand that the installed lib version is below required rust client version.

Copy link
Member

@PierreZ PierreZ left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Left a few comments, but LGTM

// the cluster. Thus, we catch it by doing a get version request to establish the connection
// The 3000ms timeout is a guard to avoid waiting forever when the cli cannot talk to any coordinators
loop {
let trx = db.create_trx().expect("could not create transaction");
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If the first-ever transaction is always failing, I think we can put it before the loop with a expect_err

// when using external clients, it will throw cluster_version_changed for the first time establish the connection to
// the cluster. Thus, we catch it by doing a get version request to establish the connection
// The 3000ms timeout is a guard to avoid waiting forever when the cli cannot talk to any coordinators
loop {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you replace the loop with a db.run? Is 1039 retryable?

}
break;
}
// write initial value
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we can just do a set/get for the test

@@ -72,7 +72,19 @@ impl FdbApiBuilder {
self.runtime_version,
fdb_sys::FDB_API_VERSION as i32,
)
})?;
}).map_err(|e| {
// 2203: api_version_not_supported
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is pretty cool 馃憤

@coveralls
Copy link

Pull Request Test Coverage Report for Build 9033137811

Details

  • 0 of 7 (0.0%) changed or added relevant lines in 1 file are covered.
  • 24 unchanged lines in 5 files lost coverage.
  • Overall coverage decreased (-0.1%) to 74.038%

Changes Missing Coverage Covered Lines Changed/Added Lines %
foundationdb/src/api.rs 0 7 0.0%
Files with Coverage Reduction New Missed Lines %
target/x86_64-unknown-linux-gnu/debug/build/foundationdb-3399e84901f79ea6/out/options.rs 1 9.24%
foundationdb/src/transaction.rs 1 84.99%
foundationdb/src/directory/mod.rs 2 92.17%
foundationdb-bindingtester/src/main.rs 7 87.59%
foundationdb/src/directory/directory_partition.rs 13 70.69%
Totals Coverage Status
Change from base Build 8685723028: -0.1%
Covered Lines: 4312
Relevant Lines: 5824

馃挍 - Coveralls

@PierreZ
Copy link
Member

PierreZ commented May 20, 2024

Could you rebase on branch on main? macos's CI was broken because of #138

* Gives an explicit error when the target FoundationDB client version
  is not supported by the locally installed FoundationDB client lib.

Signed-off-by: AlexandreBrg <alexandre.burgoni@clever-cloud.com>
* Creates an example which run a transaction with multiple
  FoundationDB API Client, allowing to support multiple versions.

Signed-off-by: AlexandreBrg <alexandre.burgoni@clever-cloud.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants