automata/event/filter

Types

Pure predicate over events with a body payload type.

Filters are values, not callbacks: every constructor returns a Filter(body) and combinators (all_of, any_of, negate) work over those values. The opaque shape lets future versions introduce structural inspection (e.g. logging which leaf rejected an event) without a public API change.

pub opaque type Filter(body)

Values

pub fn all_of(
  filters filters: List(Filter(body)),
) -> Filter(body)

Logical AND across all filters. An empty list is always.

pub fn always() -> Filter(body)

A filter that accepts every event. Useful as the identity element for all_of (the empty list of filters reduces to always).

pub fn any_of(
  filters filters: List(Filter(body)),
) -> Filter(body)

Logical OR across all filters. An empty list is never.

pub fn by_attribute(
  key key: String,
  value value: String,
) -> Filter(body)
pub fn by_causation_id(id id: String) -> Filter(body)
pub fn by_correlation_id(id id: String) -> Filter(body)
pub fn by_source(source source: source.Source) -> Filter(body)
pub fn by_source_id(id id: String) -> Filter(body)
pub fn by_source_kind(
  kind kind: source.SourceKind,
) -> Filter(body)
pub fn by_trace_id(id id: String) -> Filter(body)
pub fn has_attribute(key key: String) -> Filter(body)
pub fn keep(
  filter filter: Filter(body),
  events events: List(event.Event(body)),
) -> List(event.Event(body))
pub fn matches(
  filter filter: Filter(body),
  event event: event.Event(body),
) -> Bool
pub fn negate(filter filter: Filter(body)) -> Filter(body)

Logical negation. Named negate because not is a reserved word.

pub fn never() -> Filter(body)

A filter that rejects every event. Useful as the identity element for any_of (the empty list of filters reduces to never).

pub fn occurred_after(
  after after: ast.ValidDateTime,
) -> Filter(body)
pub fn occurred_before(
  before before: ast.ValidDateTime,
) -> Filter(body)
pub fn occurred_between(
  from from: ast.ValidDateTime,
  until until: ast.ValidDateTime,
) -> Filter(body)

Match events whose occurred_at falls in [from, until] (inclusive).

pub fn on_body(check check: fn(body) -> Bool) -> Filter(body)

Lift a body-only predicate into a Filter(body). Useful for constructing body-shape filters in automata/event/builtin/filter.

pub fn on_body_option(
  extract extract: fn(body) -> option.Option(a),
  check check: fn(a) -> Bool,
) -> Filter(body)

Lift a body-to-Option(value) extractor and a value predicate.

Returns False when the extractor yields None. Used by builtin filters that target a specific variant (e.g. FileModified.path).

pub fn predicate(
  check check: fn(event.Event(body)) -> Bool,
) -> Filter(body)

Build a filter from an arbitrary predicate.

The escape hatch for conditions that the built-in constructors do not express. Prefer the typed constructors below when one fits.

pub fn reject(
  filter filter: Filter(body),
  events events: List(event.Event(body)),
) -> List(event.Event(body))
Search Document