Module khepri_condition

Condition support.

Description

Condition support.

Conditions can be used in path patterns and keep_until conditions.

A condition is an Erlang record defining a specific property. Some of them have arguments to further define the condition.

All supported conditions are described in the Data Types section.

Data Types

comparison_op()

comparison_op(Type) = {eq, Type} | {ne, Type} | {lt, Type} | {le, Type} | {gt, Type} | {ge, Type}

Comparison operator in some condition().

condition()

condition() = if_name_matches() | if_path_matches() | if_has_data() | if_data_matches() | if_node_exists() | if_payload_version() | if_child_list_version() | if_child_list_length() | if_not() | if_all() | if_any()

if_all()

if_all() = #if_all{conditions = [khepri_path:pattern_component()]}

Condition. Evaluates to true if all inner conditions evalute to true.

Record fields: Example:
#if_all{conditions = [#if_name_matches{regex = "^a"},
                      #if_has_data{has_data = true}]}.

if_any()

if_any() = #if_any{conditions = [khepri_path:pattern_component()]}

Condition. Evaluates to true if any of the inner conditions evalute to true.

Record fields: Example:
#if_any{conditions = [#if_name_matches{regex = "^a"},
                      #if_has_data{has_data = true}]}.

if_child_list_length()

if_child_list_length() = #if_child_list_length{count = non_neg_integer() | khepri_condition:comparison_op(non_neg_integer())}

Condition. Evaluates to true if the tested node's child list size corresponds to the expected value.

Record fields: Example:
#if_child_list_length{count = 1}.
#if_child_list_length{count = {gt, 10}}.

if_child_list_version()

if_child_list_version() = #if_child_list_version{version = khepri_machine:child_list_version() | khepri_condition:comparison_op(khepri_machine:child_list_version())}

Condition. Evaluates to true if the tested node's child list version corresponds to the expected value.

Record fields: Example:
#if_child_list_version{version = 1}.
#if_child_list_version{version = {gt, 10}}.

if_data_matches()

if_data_matches() = #if_data_matches{pattern = ets:match_pattern(), compiled = ets:comp_match_spec() | undefined}

Condition. Evaluates to true if the tested node has a data payload and the data payload term matches the given pattern.

Record fields: Example:
#if_data_matches{pattern = {user, '_'}}.

if_has_data()

if_has_data() = #if_has_data{has_data = boolean()}

Condition. Evaluates to true if the tested node's data payload presence corresponds to the expected state.

Record fields:

Data absence is either no payload or a non-data type of payload.

Example:
#if_has_data{has_data = false}.

if_name_matches()

if_name_matches() = #if_name_matches{regex = any | iodata() | unicode:charlist(), compiled = re_mp() | undefined}

Condition. Evaluates to true if the name of the tested node matches the condition pattern.

Record fields: Example:
#if_name_matches{regex = "^user_"}.
#if_name_matches{regex = any}.

if_node_exists()

if_node_exists() = #if_node_exists{exists = boolean()}

Condition. Evaluates to true if the tested node existence corresponds to the expected state.

Record fields: Example:
#if_node_exists{exists = false}.

if_not()

if_not() = #if_not{condition = khepri_path:pattern_component()}

Condition. Evaluates to true if the inner condition evalutes to false.

Record fields: Example:
#if_not{condition = #if_name_matches{regex = "^a"}}.

if_path_matches()

if_path_matches() = #if_path_matches{regex = any | iodata() | unicode:charlist(), compiled = re_mp() | undefined}

Condition. Evaluates to true if the name of the tested node matches the condition pattern. If it does not match, child node names are tested recursively.

Record fields: Example:
#if_path_matches{regex = "^user_"}.
#if_path_matches{regex = any}.

if_payload_version()

if_payload_version() = #if_payload_version{version = khepri_machine:payload_version() | khepri_condition:comparison_op(khepri_machine:payload_version())}

Condition. Evaluates to true if the tested node's payload version corresponds to the expected value.

Record fields: Example:
#if_payload_version{version = 1}.
#if_payload_version{version = {gt, 10}}.

keep_until()

keep_until() = #{khepri_path:path() => condition()}

re_mp()

re_mp() = tuple()

Function Index

is_valid/1

Function Details

is_valid/1

is_valid(Condition) -> IsValid


Generated by EDoc