eval

package
v0.2.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Dec 18, 2025 License: MIT Imports: 15 Imported by: 0

Documentation

Overview

Package eval provides an Evaluator to run CEL expressions.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Cache

type Cache interface {
	Get(expr string) (ast *cel.Ast, ok bool)
	Set(expr string, ast *cel.Ast) error
}

type Config

type Config struct {
	EnvOptions []cel.EnvOption
	Cache      Cache
}

type Evaluator

type Evaluator struct {
	// contains filtered or unexported fields
}

Evaluator supports running and optionally caching CEL expressions.

func NewEvaluator

func NewEvaluator(cnf *Config) (*Evaluator, error)

func (*Evaluator) CompileAndCache

func (e *Evaluator) CompileAndCache(expr string) (*cel.Ast, error)

func (*Evaluator) Eval

func (e *Evaluator) Eval(expr string, input any) (ref.Val, error)

type FileCache

type FileCache struct {
	// contains filtered or unexported fields
}

func NewFileCache

func NewFileCache(filename string) (*FileCache, error)

NewFileCache creates a Cache that can persist to a file.

This function will read the file. The caller will need to run the FileCache.Save method to save the file.

func NewFileCacheWithContent

func NewFileCacheWithContent(content []byte, filename string) (*FileCache, error)

NewFileCacheWithContent creates a FileCache with existing content, e.g. from an embedded file.

Optionally, set a filename and call FileCache.Save to save the file.

func (*FileCache) Get

func (c *FileCache) Get(expr string) (*cel.Ast, bool)

func (*FileCache) Save

func (c *FileCache) Save() error

func (*FileCache) Set

func (c *FileCache) Set(expr string, ast *cel.Ast) error

Directories

Path Synopsis
Package celfuncs provides functions for use in a Common Expression Language (CEL) environment.
Package celfuncs provides functions for use in a Common Expression Language (CEL) environment.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL