Documentation
¶
Overview ¶
Package celenv builds CEL type environments from EvaluationContext proto message descriptors. The environment declares a "ctx" variable of the message type and registers prefix-stripped enum constants for each enum type referenced by the context's fields (e.g., PLAN_LEVEL_ENTERPRISE becomes accessible as PlanLevel.ENTERPRISE in CEL expressions).
Index ¶
- func BoundedDimsFromDescriptor(md protoreflect.MessageDescriptor) map[string]bool
- func ClassifyDimensions(conditions []*cel.Ast, values []*pbflagsv1.FlagValue, ...) map[string]*DimensionMeta
- func New(md protoreflect.MessageDescriptor) (*cel.Env, error)
- type CompiledExpr
- type Compiler
- type DimClassification
- type DimensionMeta
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func BoundedDimsFromDescriptor ¶
func BoundedDimsFromDescriptor(md protoreflect.MessageDescriptor) map[string]bool
BoundedDimsFromDescriptor returns the set of inherently bounded dimension names (enum or bool fields) from an EvaluationContext message descriptor.
func ClassifyDimensions ¶
func ClassifyDimensions( conditions []*cel.Ast, values []*pbflagsv1.FlagValue, boundedDims map[string]bool, ) map[string]*DimensionMeta
ClassifyDimensions analyzes a flag's compiled condition chain and classifies each referenced dimension for cache key construction.
conditions and values must have the same length. conditions[i] is the compiled AST (nil for "otherwise") and values[i] is the flag value. boundedDims is the set of inherently bounded dimensions (enum/bool).
func New ¶
func New(md protoreflect.MessageDescriptor) (*cel.Env, error)
New creates a CEL type-checking environment from an EvaluationContext message descriptor. It declares a "ctx" variable of the message type and registers prefix-stripped enum constants for each enum type referenced by the context's fields.
Types ¶
type CompiledExpr ¶
type CompiledExpr struct {
Source string // original CEL source text
AST *cel.Ast // type-checked AST (for dimension extraction)
Program cel.Program // compiled program (for evaluation)
}
CompiledExpr holds a compiled CEL expression ready for evaluation.
type Compiler ¶
type Compiler struct {
// contains filtered or unexported fields
}
Compiler compiles and type-checks CEL expressions against the EvaluationContext. Compiled programs can be reused across evaluations.
func NewCompiler ¶
func NewCompiler(md protoreflect.MessageDescriptor) (*Compiler, error)
NewCompiler creates a compiler for the given EvaluationContext message descriptor.
type DimClassification ¶
type DimClassification string
DimClassification describes how a dimension is used for cache key construction.
const ( Bounded DimClassification = "bounded" FiniteFilterUniform DimClassification = "finite_filter_uniform" FiniteFilterDistinct DimClassification = "finite_filter_distinct" Unbounded DimClassification = "unbounded" )
type DimensionMeta ¶
type DimensionMeta struct {
Classification DimClassification `json:"classification"`
LiteralSet []string `json:"literal_set,omitempty"`
}
DimensionMeta holds classification metadata for a single dimension as used by a flag's condition chain.