Transactions
A transaction is the unit of change to the project graph: a set of deltas to the graph.
Committing a transaction applies its changes to the project graph; a local transaction can also be reverted.
A function always sees a local transactional view of the project graph with all its deltas applied.
Committing a transaction applies its changes to the project graph; a local transaction can also be reverted.
A function always sees a local transactional view of the project graph with all its deltas applied.
Consistency Modes
There are two consistency modes, weak and strong. Weak transactions give the most scalability and performance; strong transactions give a higher level of consistency. Diafunc is an analytical platform, so for most use cases the recommendation is weak transactions, eventual consistency, deliberate data redundancy, idempotent operations, and functions that map between immutable data structures.
Transactional View
In both consistency modes, a transaction is invisible to others until it is committed. A function evaluation works on a transactional view of the project graph: its changes are visible only within its own transaction. Committing the transaction applies the changes to the global project graph. A transaction that is neither committed nor reverted when the evaluation finishes is committed automatically.
In the left panel the elements marked + are added and the elements marked − are removed by the transaction; the right panel is the graph as everyone else reads it until the transaction is committed.
In the left panel the elements marked + are added and the elements marked − are removed by the transaction; the right panel is the graph as everyone else reads it until the transaction is committed.
Commit
The commit applies all changes to the project graph and makes them visible to other functions and transactions.
Committing the current transaction
//performing changes ...
diafunc.commit();Revert
A transaction can be reverted as long as it is not committed.
Reverting the current transaction
//performing changes ...
diafunc.revert();Sequential Transactions
A function can perform several transactions in sequence.
Performing sequential transactions
//performing changes ...
diafunc.commit();
//performing changes ...
diafunc.commit();
//performing changes ...
diafunc.commit();
Nested Transactions
Transactions can also be nested.
Performing nested transactions
var nestedTransaction1 = diafunc.transaction();
var nestedTransaction2 = diafunc.transaction();
//performing changes ...
nestedTransaction1.commit();
nestedTransaction2.commit();