Skip to content

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

Open
@alexjpwalker

Description

@alexjpwalker

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.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions