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:
is_remote_call_valid/3
for the complete list.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:khepri_fun
)tx_abort() = {aborted, any()}
tx_fun() = fun(() -> tx_fun_result())
tx_fun_bindings() = #{Name::atom() => Value::any()}
tx_fun_result() = any()
put/2 | Creates or modifies a specific tree node in the tree structure. |
put/3 | Creates 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 |
put(PathPattern, Payload) -> Result
PathPattern = khepri_path:pattern()
Payload = khepri_machine:payload()
Result = khepri_machine:result()
Creates or modifies a specific tree node in the tree structure.
put(PathPattern, Payload, Extra) -> Result
PathPattern = khepri_path:pattern()
Payload = khepri_machine:payload()
Extra = #{keep_until => khepri_condition:keep_until()}
Result = khepri_machine:result()
Creates or modifies a specific tree node in the tree structure.
get(PathPattern) -> any()
get(PathPattern, Options) -> any()
exists(Path) -> Exists
Path = khepri_path:pattern()
Exists = boolean()
has_data(Path) -> HasData
Path = khepri_path:pattern()
HasData = boolean()
list(Path) -> any()
find(Path, Condition) -> any()
delete(PathPattern) -> any()
abort(Reason) -> no_return()
Reason = any()
to_standalone_fun(Fun, ReadWrite) -> StandaloneFun | no_return()
Fun = function()
ReadWrite = auto | boolean()
StandaloneFun = khepri_fun:standalone_fun()
Generated by EDoc