Documentation
¶
Overview ¶
Package cel provides a script engine implementation using Google's CEL-Go (Common Expression Language — https://github.com/google/cel-go). CEL is a non-Turing-complete expression language designed for simplicity, safety, and fast evaluation. Unlike full scripting languages, CEL evaluates a single expression per "script" and supports compile-time type checking.
Construction:
eng, _ := cel.New(ctx)
eng.Init(ctx)
eng.RegisterGlobal("name", "world")
result, _ := eng.ExecuteString(ctx, "greet", `"Hello " + name`)
The engine supports hot-reload via StartWatch/StopWatch when the bound Source implements the Watcher interface.
Index ¶
Constants ¶
This section is empty.
Variables ¶
View Source
var ( // ErrCELEngineNotInitialized is returned when an operation is invoked // before Init or after Close. ErrCELEngineNotInitialized = errors.New("cel engine not initialized") // ErrCELEngineAlreadyInitialized is returned when Init is called on an // already-initialized engine. ErrCELEngineAlreadyInitialized = errors.New("cel engine already initialized") // ErrCLEEnvNotInitialized is returned when the underlying cel-go Env is nil. ErrCLEEnvNotInitialized = errors.New("cel env not initialized") // ErrCELCompileFailed is returned when compiling a CEL expression fails. ErrCELCompileFailed = errors.New("cel compile failed") // ErrCELNoExpressionLoaded is returned when Execute is called but no // expression has been loaded. ErrCELNoExpressionLoaded = errors.New("cel no expression loaded") // ErrCELEvalFailed is returned when evaluating a CEL expression fails. ErrCELEvalFailed = errors.New("cel eval failed") // ErrCELFunctionNotFound is returned when CallFunction cannot find the // named function. ErrCELFunctionNotFound = errors.New("cel function not found") // ErrCELGlobalNotFound is returned when GetGlobal cannot find the named // variable. ErrCELGlobalNotFound = errors.New("cel global not found") )
Sentinel errors returned by the CEL engine.
Functions ¶
This section is empty.
Types ¶
This section is empty.
Click to show internal directories.
Click to hide internal directories.