Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type ASTSet ¶
type ASTSet struct {
// contains filtered or unexported fields
}
ASTSet represents a collection of compiledAST and their associated cel.Env.
func CompileASTs ¶
func CompileASTs[T Expression]( expressions []T, env *cel.Env, envOpts ...cel.EnvOption, ) (set ASTSet, err error)
CompileASTs parses and type checks a set of expressions, producing a resulting ASTSet. The value can then be converted to a ProgramSet via ASTSet.ToProgramSet or ASTSet.ReduceResiduals. Use Compile instead if no cel.ProgramOption args need to be provided or residuals do not need to be computed.
func (ASTSet) ReduceResiduals ¶
func (set ASTSet) ReduceResiduals(opts ...cel.ProgramOption) (ProgramSet, error)
ReduceResiduals generates a ProgramSet, performing a partial evaluation of the ASTSet to optimize the expression. If the expression is optimized to either a true or empty string constant result, no compiledProgram is generated for it. The main usage of this is to elide tautological expressions from the final result.
func (ASTSet) ToProgramSet ¶
func (set ASTSet) ToProgramSet(opts ...cel.ProgramOption) (out ProgramSet, err error)
ToProgramSet generates a ProgramSet from the specified ASTs.
type Expression ¶
Expression is the read-only interface of either validate.Constraint or private.Constraint which can be the source of a CEL expression.
type Now ¶
type Now struct { // TS is the already resolved timestamp. If unset, the field is populated with // timestamppb.Now. TS *timestamppb.Timestamp }
Now implements interpreter.Activation, providing a lazily produced timestamp for accessing the variable `now` that's constant within an evaluation.
func (*Now) Parent ¶
func (n *Now) Parent() interpreter.Activation
type ProgramSet ¶
type ProgramSet []compiledProgram
ProgramSet is a list of compiledProgram expressions that are evaluated together with the same input value. All expressions in a ProgramSet may refer to a `this` variable.
func Compile ¶
func Compile[T Expression]( expressions []T, env *cel.Env, envOpts ...cel.EnvOption, ) (set ProgramSet, err error)
Compile produces a ProgramSet from the provided expressions in the given environment. If the generated cel.Program require cel.ProgramOption params, use CompileASTs instead with a subsequent call to ASTSet.ToProgramSet.
func (ProgramSet) Eval ¶
func (s ProgramSet) Eval(val any, failFast bool) error
Eval applies the contained expressions to the provided `this` val, returning either *errors.ValidationError if the input is invalid or errors.RuntimeError if there is a type or range error. If failFast is true, execution stops at the first failed expression.
type Variable ¶
type Variable struct { // Next is the parent activation Next interpreter.Activation // Name is the variable's name Name string // Val is the value for this variable Val any }
Variable implements interpreter.Activation, providing a lightweight named variable to cel.Program executions.
func (*Variable) Parent ¶
func (v *Variable) Parent() interpreter.Activation
type VariablePool ¶
func (*VariablePool) Get ¶
func (p *VariablePool) Get() *Variable
func (*VariablePool) Put ¶
func (p *VariablePool) Put(v *Variable)