PropertyTable.Matcher behaviour (property_table v0.3.4)

Copy Markdown View Source

Behaviour for customizing the Matcher logic for filtering and dispatching events

Summary

Callbacks

Check whether a pattern is valid

Check whether a property is valid

Build an ETS match-spec for pattern

Returns true if the pattern matches the specified property

Callbacks

check_pattern(pattern)

@callback check_pattern(PropertyTable.pattern()) :: :ok | {:error, Exception.t()}

Check whether a pattern is valid

Returns :ok on success or {:error, error} where error is an Exception struct with information about the issue.

check_property(property)

@callback check_property(PropertyTable.property()) :: :ok | {:error, Exception.t()}

Check whether a property is valid

Returns :ok on success or {:error, error} where error is an Exception struct with information about the issue.

match_spec(pattern)

(optional)
@callback match_spec(PropertyTable.pattern()) :: [{tuple(), [term()], [term()]}] | :error

Build an ETS match-spec for pattern

This is an optional callback. When implemented, PropertyTable.match/2 will call it to obtain a match-spec and run the scan with :ets.select/2. This can be much faster on large tables than iterating over rows calling matches?/2. Return :error to fall back to the generic matches?/2 path.

The match-spec must handle {property, value, meta} triples. Return rows unmodified by specifying [:"$_"] in the third tuple element.

matches?(pattern, property)

@callback matches?(PropertyTable.pattern(), PropertyTable.property()) :: boolean()

Returns true if the pattern matches the specified property