Module khepri_tx

Khepri API for transactional queries and updates.

Description

Khepri API for transactional queries and updates.

Transactions are anonymous functions which take no arguments, much like what Mnesia supports. However, unlike with Mnesia, transaction functions in Khepri are restricted:

The reason is that the transaction function must always have the exact same outcome given its inputs. Indeed, the transaction function is executed on every Ra cluster members participating in the consensus. The function must therefore modify the Khepri state (the database) identically on all Ra members. This is also true for Ra members joining the cluster later or catching up after a network partition.

To achieve that:
  1. The code of the transaction function is extracted from the its initial Erlang module. This way, the transaction function does not depend on the initial module availability and is not affected by a module reload. See khepri_fun)
  2. The code is verified to make sure it does not perform any denied operations.
  3. The extracted transaction function is stored as a Khepri state machine command in the Ra journal to be replicated on all Ra members.

Data Types

tx_abort()

tx_abort() = {aborted, any()}

tx_fun()

tx_fun() = fun(() -> tx_fun_result())

tx_fun_bindings()

tx_fun_bindings() = #{Name::atom() => Value::any()}

tx_fun_result()

tx_fun_result() = any() | no_return()

Function Index

put/2Creates or modifies a specific tree node in the tree structure.
put/3Creates or modifies a specific tree node in the tree structure.
get/1
get/2
exists/1
has_data/1
list/1
find/2
delete/1
abort/1
to_standalone_fun/2

Function Details

put/2

put(PathPattern, Payload) -> Result

Creates or modifies a specific tree node in the tree structure.

put/3

put(PathPattern, Payload, Extra) -> Result

Creates or modifies a specific tree node in the tree structure.

get/1

get(PathPattern) -> any()

get/2

get(PathPattern, Options) -> any()

exists/1

exists(Path) -> Exists

has_data/1

has_data(Path) -> HasData

list/1

list(Path) -> any()

find/2

find(Path, Condition) -> any()

delete/1

delete(PathPattern) -> any()

abort/1

abort(Reason) -> no_return()

to_standalone_fun/2

to_standalone_fun(Fun, ReadWrite) -> StandaloneFun | no_return()


Generated by EDoc