ExDatalog.Constraints.BeamCallback (ExDatalog v0.5.0)

Copy Markdown View Source

Evaluation of BEAM callback predicates.

A callback applies an Elixir function to argument values resolved (by variable name) from the current binding. The function must be deterministic and side-effect free — these are caller contracts, not enforced.

The engine enforces only:

  • Timeout — the call runs in a spawn_monitor-ed process with a configurable timeout (:callback_timeout_ms, default 100ms). A timeout filters the binding. Late result messages are flushed from the mailbox.
  • Exception isolation — a raised exception filters the binding.

Boolean callbacks (result: nil) act as filters: true keeps the binding, false/timeout/exception drops it. Value-returning callbacks (result: {:var, name}) bind the return value to name.

Summary

Functions

Applies a callback against a binding.

Functions

apply_callback(callback, binding, opts)

@spec apply_callback(ExDatalog.IR.Callback.t(), map(), keyword()) ::
  {:ok, map()} | :filter

Applies a callback against a binding.

Returns {:ok, binding} (boolean true, or value bound) or :filter (boolean false, unbound argument, timeout, or exception).