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’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make Write and Read transactions distinguishable at compile-time #680

Open
alexjpwalker opened this issue Aug 30, 2024 · 0 comments
Open

Comments

@alexjpwalker
Copy link
Member

Problem to Solve

Suppose you're writing a function that takes a Transaction parameter, that you know needs to write to the DB, and would like the compilation to fail if you accidentally pass it a transaction that could be read-only.

Current Workaround

Use Transaction / TypeDBTransaction and write correct code.

Proposed Solution

@dmitrii-ubskii has proposed the following structure for the Rust driver:

pub struct Read;
pub struct Write;
pub struct Transaction<Type>; // Read or Write

It's achievable, but requires buy-in from the rest of the architecture, as those generics are infectious.

Additional Information

In Java we'd have used subclasses - TypeDBTransaction.Write and TypeDBTransaction.Read.

@alexjpwalker alexjpwalker changed the title Make compilation able to differentiate a Write and a Read transaction Make Write and Read transactions distinguishable at compile-time Aug 30, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant