khepri_payload (khepri v0.6.0)
Khepri payloads.
Payloads are the structure used to attach something to a tree node in the store. Khepri supports the following payloads:- No payload at all (
no_payload()
- Data payload used to store any Erlang term (
data()
) - Stored procedure payload used to store functions (
sproc()
)
wrap/1
function already called internally.
Link to this section Summary
Types
Internal structure to wrap any Erlang term before it can be stored in a tree node.
Internal value used to mark that a tree node has no payload attached.
All types of payload stored in the nodes of the tree structure.
Internal structure to wrap an anonymous function before it can be stored in a tree node and later executed.
Functions
Returns the same term wrapped into an internal structure ready to be stored in the tree.
See also: data().
Returns the internal value used to mark that a tree node has no payload attached.
See also: no_payload().
Returns the same function wrapped into an internal structure ready to be stored in the tree.
See also: sproc().
Automatically detects the payload type and ensures it is wrapped in one of the internal types.
Link to this section Types
Link to this type
data/0
-type data() :: #p_data{}.
Internal structure to wrap any Erlang term before it can be stored in a tree node.
The only constraint is the conversion to an Erlang binary must be supported by this term.
Link to this type
no_payload/0
-type no_payload() :: '$__NO_PAYLOAD__'.
Link to this type
payload/0
-type payload() :: no_payload() | data() | sproc().
All types of payload stored in the nodes of the tree structure.
Beside the absence of payload, the only type of payload supported is data.
Link to this type
sproc/0
-type sproc() :: #p_sproc{}.
Link to this section Functions
Link to this function
data(Term)
-spec data(Term) -> Payload when Term :: khepri:data(), Payload :: data().
See also: data().
Link to this function
none()
-spec none() -> no_payload().
See also: no_payload().
Link to this function
sproc(Fun)
-spec sproc(Fun) -> Payload when Fun :: khepri_fun:standalone_fun() | fun(), Payload :: sproc().
See also: sproc().
Link to this function
wrap(Payload)
-spec wrap(Payload) -> WrappedPayload when Payload :: payload() | khepri:data() | fun(), WrappedPayload :: payload().
Automatically detects the payload type and ensures it is wrapped in one of the internal types.
The internal types make sure we avoid any collision between any user-provided terms and internal structures.