khepri_evf (khepri v0.6.0)

Khepri event filters.

Link to this section Summary

Types

An event filter.

An event filter priority.

A tree event filter.

Tree event filter properties.

Functions

Returns the priority of the event filter.
Sets the priority of the event filter.
Constructs a tree event filter.

See also: tree/2.

Constructs a tree event filter.

See also: tree_event_filter().

Automatically detects the event filter type and ensures it is wrapped in one of the internal types.

Link to this section Types

Link to this type

event_filter/0

-type event_filter() :: tree_event_filter().

An event filter.

The following event filters are supported:An event filter can be explicitly constructed using the functions provided in this module. However, some common types will be automatically detected and converted to an event filter with default properties. See each event filter type for more details.
-type priority() :: integer().

An event filter priority.

This is an integer to prioritize event filters: the greater the priority, the more it is prioritized. Negative integers are allowed.

The default priority is 0.
Link to this type

tree_event_filter/0

-type tree_event_filter() :: #evf_tree{}.

A tree event filter.

It takes a path pattern to monitor and optionally properties.
Link to this type

tree_event_filter_props/0

-type tree_event_filter_props() ::
    #{on_actions => [create | update | delete], priority => khepri_evf:priority()}.

Tree event filter properties.

The properties are:
  • on_actions: a list of actions to filter among create, update and delete; the default is to react to all of them.
  • priority: a priority()
A Khepri path, whether it is a native path or a Unix-like path, can be used as a tree event filter. It will be automatically converted to a tree event filter with default properties.

Link to this section Functions

Link to this function

get_priority(EventFilter)

-spec get_priority(EventFilter) -> Priority when EventFilter :: event_filter(), Priority :: priority().
Returns the priority of the event filter.
Link to this function

set_priority(EventFilter, Priority)

-spec set_priority(EventFilter, Priority) -> EventFilter
                when EventFilter :: event_filter(), Priority :: priority().
Sets the priority of the event filter.
Link to this function

tree(PathPattern)

-spec tree(PathPattern) -> EventFilter
        when PathPattern :: khepri_path:pattern() | string(), EventFilter :: tree_event_filter().
Constructs a tree event filter.

See also: tree/2.

Link to this function

tree(PathPattern, Props)

-spec tree(PathPattern, Props) -> EventFilter
        when
            PathPattern :: khepri_path:pattern() | string(),
            Props :: tree_event_filter_props(),
            EventFilter :: tree_event_filter().
Constructs a tree event filter.

See also: tree_event_filter().

-spec wrap(Input) -> EventFilter
        when
            Input :: event_filter() | khepri_path:pattern() | string(),
            EventFilter :: event_filter().
Automatically detects the event filter type and ensures it is wrapped in one of the internal types.