reckon_db_filters (reckon_db v1.2.7)

View Source

Khepri event filters for reckon-db

Provides filter builders for Khepri event subscriptions. These filters are used to watch for new events matching specific criteria.

Summary

Functions

Create a filter matching events with a specific pattern in their metadata

Create a filter matching events with a specific pattern in their payload

Create a filter for events of a specific type

Create a filter for all events in a specific stream

Create a filter matching events with specific tags

Functions

by_event_pattern(EventPattern)

-spec by_event_pattern(map()) -> khepri_evf:tree().

Create a filter matching events with a specific pattern in their metadata

The pattern is a map that must be a subset of the event record.

by_event_payload(PayloadPattern)

-spec by_event_payload(map()) -> khepri_evf:tree().

Create a filter matching events with a specific pattern in their payload

The pattern is checked against the data field of the event.

by_event_type(EventType)

-spec by_event_type(binary()) -> khepri_evf:tree().

Create a filter for events of a specific type

Uses #event{} record pattern matching since events are stored as records.

by_stream(Stream)

-spec by_stream(binary()) -> khepri_evf:tree() | {error, invalid_stream}.

Create a filter for all events in a specific stream

Special case: the binary <<"$all">> matches events in all streams.

by_tags(Tags)

-spec by_tags([binary()]) -> khepri_evf:tree().

Create a filter matching events with specific tags

Note: Khepri's pattern matching doesn't natively support list membership, so this creates a broad filter that matches all events with tags. The actual tag filtering must be done by the subscription consumer. For efficient tag-based queries, use reckon_db_streams:read_by_tags/4.