Documentation
¶
Overview ¶
In package eval — what evaluation operates on.
Index ¶
- func Bucket(flagKey string, user DataContext, rollout Rollout) bool
- func NewCELEnv() (*cel.Env, error)
- func NewCELEnvForContext(schema *ContextSchema) (*cel.Env, error)
- type BucketTrace
- type CompiledRule
- type ContextField
- type ContextSchema
- type ContextType
- type DataContext
- type Engine
- func (e *Engine) CompileFlag(key string, config FlagConfig) (*Flag, error)
- func (e *Engine) CompileFlagForContext(key string, config FlagConfig, schema *ContextSchema) (*Flag, error)
- func (e *Engine) Evaluate(flag *Flag, data DataContext) FlagValue
- func (e *Engine) EvaluateConfig(config FlagConfig, data DataContext) EvaluationTrace
- func (e *Engine) EvaluateConfigForContext(config FlagConfig, schema *ContextSchema, data DataContext) EvaluationTrace
- func (e *Engine) EvaluateResult(flag *Flag, data DataContext) EvaluationResult
- func (e *Engine) EvaluateTrace(flag *Flag, data DataContext) EvaluationTrace
- type EvalContext
- type EvaluationResult
- type EvaluationTrace
- type Flag
- type FlagConfig
- type FlagValue
- type MatchedRuleTrace
- type Rollout
- type Rule
- type RuleEvaluationTrace
- type ValueType
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func NewCELEnvForContext ¶
func NewCELEnvForContext(schema *ContextSchema) (*cel.Env, error)
Types ¶
type BucketTrace ¶
type CompiledRule ¶
type ContextField ¶
type ContextField struct {
Path string `json:"path"`
Type ContextType `json:"type"`
}
type ContextSchema ¶
type ContextSchema struct {
ID string `json:"id"`
Name string `json:"name"`
Description string `json:"description,omitempty"`
Fields []ContextField `json:"fields"`
CreatedAt time.Time `json:"created_at"`
UpdatedAt time.Time `json:"updated_at"`
CreatedBy *string `json:"created_by,omitempty"`
DeletedBy *string `json:"deleted_by,omitempty"`
}
type ContextType ¶
type ContextType string
const ( ContextTypeString ContextType = "string" ContextTypeInt ContextType = "int" ContextTypeDouble ContextType = "double" ContextTypeBool ContextType = "bool" ContextTypeTimestamp ContextType = "timestamp" ContextTypeList ContextType = "list" ContextTypeMap ContextType = "map" )
func (ContextType) Valid ¶
func (t ContextType) Valid() bool
type DataContext ¶
type Engine ¶
type Engine struct {
// contains filtered or unexported fields
}
func (*Engine) CompileFlag ¶
func (e *Engine) CompileFlag(key string, config FlagConfig) (*Flag, error)
func (*Engine) CompileFlagForContext ¶
func (e *Engine) CompileFlagForContext(key string, config FlagConfig, schema *ContextSchema) (*Flag, error)
func (*Engine) Evaluate ¶
func (e *Engine) Evaluate(flag *Flag, data DataContext) FlagValue
Evaluate each rule in flag and return the matched rule value, or the flag default value.
func (*Engine) EvaluateConfig ¶
func (e *Engine) EvaluateConfig(config FlagConfig, data DataContext) EvaluationTrace
func (*Engine) EvaluateConfigForContext ¶
func (e *Engine) EvaluateConfigForContext(config FlagConfig, schema *ContextSchema, data DataContext) EvaluationTrace
func (*Engine) EvaluateResult ¶
func (e *Engine) EvaluateResult(flag *Flag, data DataContext) EvaluationResult
func (*Engine) EvaluateTrace ¶
func (e *Engine) EvaluateTrace(flag *Flag, data DataContext) EvaluationTrace
type EvalContext ¶
type EvaluationResult ¶
type EvaluationTrace ¶
type EvaluationTrace struct {
Key string
Type ValueType
Enabled bool
DefaultValue any
Value any
Reason string
Error string
MatchedRule *MatchedRuleTrace
Bucket *BucketTrace
RuleResults []RuleEvaluationTrace
}
func (EvaluationTrace) Result ¶
func (t EvaluationTrace) Result() EvaluationResult
type Flag ¶
type Flag struct {
Key string
Type ValueType
Enabled bool
Rules []CompiledRule // pre-compiled, ready to evaluate
DefaultValue any
}
In memory highly accessed types
type FlagConfig ¶
type FlagConfig struct {
Key string `json:"key"`
Description string `json:"description,omitempty"`
Type ValueType `json:"type"`
Enabled bool `json:"enabled"`
Rules []Rule `json:"rules"`
DefaultValue any `json:"default_value"`
ContextID *string `json:"context_id,omitempty"`
CreatedAt time.Time `json:"created_at"`
UpdatedAt time.Time `json:"updated_at"`
CreatedBy *string `json:"created_by,omitempty"`
UpdatedBy *string `json:"updated_by,omitempty"`
DeletedBy *string `json:"deleted_by,omitempty"`
}
type MatchedRuleTrace ¶
type Rule ¶
type Rule struct {
ID string `json:"id"`
Description string `json:"description,omitempty"`
Expression string `json:"expression"`
Rollout Rollout `json:"rollout"`
Value any `json:"value"`
CreatedAt time.Time `json:"created_at"`
UpdatedAt time.Time `json:"updated_at"`
CreatedBy *string `json:"created_by,omitempty"`
UpdatedBy *string `json:"updated_by,omitempty"`
DeletedBy *string `json:"deleted_by,omitempty"`
}
type RuleEvaluationTrace ¶
Click to show internal directories.
Click to hide internal directories.