A checked CEL expression together with the CEL.Env it was checked
against, ready to evaluate any number of times.
env = CEL.Env.build(vars: [name: :string])
{:ok, program} = CEL.compile(~s|"hello, " + name|, env)
CEL.Program.eval(program, %{name: "world"})
#=> {:ok, {:string, "hello, world"}}Get one from CEL.compile/2, or with new/2 from a CEL.Checked you
already have. Literal regular expressions are compiled once, here.
Summary
Types
@type t() :: %CEL.Program{ checked: CEL.Checked.t(), env: CEL.Env.t(), regexes: %{required(CEL.Checked.expr_id()) => Regex.t()} }
Functions
@spec eval(t(), map() | keyword()) :: {:ok, CEL.Value.t()} | {:unknown, CEL.Unknown.t()} | {:error, CEL.Error.t()}
Evaluates a compiled program with the supplied variable bindings.
@spec eval!(t(), map() | keyword()) :: CEL.Value.t()
Evaluates a compiled program, raising on errors and unknown results.
@spec new(CEL.Checked.t(), CEL.Env.t()) :: t()
Bundles a previously checked expression with the environment it was checked
against, returning a Program ready for eval/2.
Most callers should use CEL.compile/2, which parses, checks, and
bundles in one call. Use this constructor when you already hold a
CEL.Checked and the matching CEL.Env — for example, to
cache the check phase and re-bundle programs with different runtime
bindings.