Documentation
¶
Index ¶
- type Config
- type ExecuteResult
- type FunctionLoader
- type Registry
- func (r *Registry) Execute(ctx context.Context, fullName string, args map[string]any) (*ExecuteResult, error)
- func (r *Registry) ExecuteInline(ctx context.Context, source string, args map[string]any) (*ExecuteResult, error)
- func (r *Registry) GetBuiltins() map[string]*executor.BuiltinFunc
- func (r *Registry) GetCompiled(ctx context.Context, name string) (*executor.CompiledFunction, bool)
- func (r *Registry) Invalidate(fullName string)
- func (r *Registry) ListCompiled() []string
- func (r *Registry) ListFunctionNames() []string
- func (r *Registry) Register(fullName, source string) error
- func (r *Registry) RegisterBuiltin(name string, bf *executor.BuiltinFunc)
- func (r *Registry) ResolveFunction(name string) (int, bool)
- func (r *Registry) SetLoader(loader FunctionLoader)
- func (r *Registry) Validate(source string) *ValidateResult
- func (r *Registry) ValidateWithLookup(source string, lookup func(string) (int, bool)) *ValidateResult
- type ValidateResult
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type ExecuteResult ¶
type ExecuteResult struct {
Value any `json:"result"`
Logs []executor.DebugEntry `json:"logs,omitempty"`
}
ExecuteResult holds the execution result along with any debug output.
func (*ExecuteResult) GetValue ¶
func (r *ExecuteResult) GetValue() any
GetValue returns the execution result value. Implements the DTLExecuteResult interface used by the formula extension.
type FunctionLoader ¶
FunctionLoader loads a function's source from external storage (e.g. database) by its fully-qualified name. The context carries workspace scope.
type Registry ¶
type Registry struct {
// contains filtered or unexported fields
}
Registry is the in-memory compiled function cache and execution engine. It owns the compiler, executor, and built-in function table.
func (*Registry) Execute ¶
func (r *Registry) Execute(ctx context.Context, fullName string, args map[string]any) (*ExecuteResult, error)
Execute runs a named function with the given argument map.
func (*Registry) ExecuteInline ¶
func (r *Registry) ExecuteInline(ctx context.Context, source string, args map[string]any) (*ExecuteResult, error)
ExecuteInline parses, compiles, and executes a DTL source string without caching.
func (*Registry) GetBuiltins ¶
func (r *Registry) GetBuiltins() map[string]*executor.BuiltinFunc
GetBuiltins returns the built-in function table (read-only use).
func (*Registry) GetCompiled ¶
GetCompiled returns a compiled user-defined function by full name. If not found in the in-memory cache, it falls back to the loader (if set) to fetch and register the function from the database.
func (*Registry) Invalidate ¶
Invalidate removes a compiled function from the cache.
func (*Registry) ListCompiled ¶
ListCompiled returns all currently compiled function names.
func (*Registry) ListFunctionNames ¶
ListFunctionNames returns all known function names (built-in and user-defined). Implements compiler.FunctionLister for "did you mean?" suggestions.
func (*Registry) Register ¶
Register parses, compiles, and caches a function from its source. Uses a loader-backed resolver when available so that cross-namespace dependencies are correctly tracked even for functions not yet in cache.
func (*Registry) RegisterBuiltin ¶
func (r *Registry) RegisterBuiltin(name string, bf *executor.BuiltinFunc)
RegisterBuiltin adds a Go-implemented function to the built-in table.
func (*Registry) ResolveFunction ¶
ResolveFunction checks if a function name is known (built-in or user-defined).
func (*Registry) SetLoader ¶
func (r *Registry) SetLoader(loader FunctionLoader)
SetLoader sets an optional function loader that is called when GetCompiled misses the in-memory cache. The loader typically queries the database.
func (*Registry) Validate ¶
func (r *Registry) Validate(source string) *ValidateResult
Validate parses and compiles source, returning validation errors.
func (*Registry) ValidateWithLookup ¶
func (r *Registry) ValidateWithLookup(source string, lookup func(string) (int, bool)) *ValidateResult
ValidateWithLookup parses and compiles source, using an optional lookup function to resolve functions not found in the in-memory registry (e.g. from the database).
type ValidateResult ¶
type ValidateResult struct {
Valid bool `json:"valid"`
Errors []compiler.CompileError `json:"errors,omitempty"`
AST *ast.FnAST `json:"-"`
}
ValidateResult contains the result of source validation.