Versions in this module Expand all Collapse all v2 v2.0.0 Jan 21, 2026 Changes in this version + const AlmanacOptionKeyAllowUndefinedFacts + const AlmanacOptionKeyCacheConditions + const ConstantFact + const DecisionAuthorize + const DecisionDecline + const DynamicFact + const EngineOptionKeyAuditTrace + const EngineOptionKeyCacheConditions + const EngineOptionKeyParallel + const EngineOptionKeySmartSkip + const EngineOptionKeyWorkerCount + const FactOptionKeyCache + const FactOptionKeyPriority + const SortByPriority + const SortDefault + const SortRuleASC + const SortRuleDESC + func DefaultPathResolver(value interface{}, path string) (interface{}, error) + func RegisterOperator(opType OperatorType, operator Operator) + type Almanac struct + func NewAlmanac(opts ...AlmanacOption) *Almanac + func (a *Almanac) AddFact(id FactID, valueOrMethod interface{}, opts ...FactOption) error + func (a *Almanac) AddFacts(facts ...*Fact) + func (a *Almanac) GetConditionResultFromCache(key string) (interface{}, bool) + func (a *Almanac) GetFactValue(factID FactID, params map[string]interface{}, path string) (interface{}, error) + func (a *Almanac) GetFactValueFromCache(factID FactID) (interface{}, bool) + func (a *Almanac) GetFacts() map[FactID]*Fact + func (a *Almanac) GetOptions() map[string]interface{} + func (a *Almanac) IsConditionCachingEnabled() bool + func (a *Almanac) PreCacheFactValue(fact *Fact) + func (a *Almanac) SetConditionResultCache(key string, result interface{}) + func (a *Almanac) TraversePath(data interface{}, path string) (interface{}, error) + type AlmanacError struct + Err error + Payload string + func (e *AlmanacError) Error() string + func (e *AlmanacError) Unwrap() error + type AlmanacOption func(*Almanac) + func AllowUndefinedFacts() AlmanacOption + func WithAlmanacConditionCaching() AlmanacOption + type Condition struct + Fact FactID + Operator OperatorType + Params map[string]interface{} + Path string + Value interface{} + func Contains(fact string, value interface{}) *Condition + func Equal(fact string, value interface{}) *Condition + func GreaterThan(fact string, value interface{}) *Condition + func GreaterThanInclusive(fact string, value interface{}) *Condition + func In(fact string, values interface{}) *Condition + func LessThan(fact string, value interface{}) *Condition + func LessThanInclusive(fact string, value interface{}) *Condition + func NotContains(fact string, value interface{}) *Condition + func NotEqual(fact string, value interface{}) *Condition + func NotIn(fact string, values interface{}) *Condition + func Regex(fact string, pattern string) *Condition + func (c *Condition) Compile() error + func (c *Condition) Evaluate(almanac *Almanac) (*ConditionResult, error) + func (c *Condition) GetCacheKey() (string, error) + func (c *Condition) GetRequiredFacts() []FactID + type ConditionError struct + Condition Condition + Err error + func (e *ConditionError) Error() string + func (e *ConditionError) Unwrap() error + type ConditionNode struct + Condition *Condition + SubSet *ConditionSet + func (n *ConditionNode) GetRequiredFacts() []FactID + func (n *ConditionNode) UnmarshalJSON(data []byte) error + type ConditionNodeResult struct + Condition *ConditionResult + ConditionSet *ConditionSetResult + type ConditionResult struct + Error string + Fact FactID + FactValue interface{} + Operator OperatorType + Path string + Result bool + Value interface{} + type ConditionSet struct + All []ConditionNode + Any []ConditionNode + None []ConditionNode + func All(conditions ...*Condition) ConditionSet + func AllSets(sets ...ConditionSet) ConditionSet + func Any(conditions ...*Condition) ConditionSet + func AnySets(sets ...ConditionSet) ConditionSet + func None(conditions ...*Condition) ConditionSet + func NoneSets(sets ...ConditionSet) ConditionSet + func (cs *ConditionSet) Compile() error + func (cs *ConditionSet) Evaluate(almanac *Almanac) (*ConditionSetResult, error) + func (cs *ConditionSet) GetCacheKey() (string, error) + func (cs *ConditionSet) GetRequiredFacts() []FactID + func (cs *ConditionSet) ReorderNodes(nodes []ConditionNode, almanac *Almanac) ([]ConditionNode, error) + type ConditionSetResult struct + Result bool + Results []ConditionNodeResult + Type ConditionType + type ConditionType string + const AllType + const AnyType + const NoneType + type ContainsOperator struct + func (o *ContainsOperator) Evaluate(factValue interface{}, compareValue interface{}) (bool, error) + type Engine struct + func NewEngine(opts ...EngineOption) *Engine + func (e *Engine) AddRule(rule *Rule) + func (e *Engine) AddRules(rules ...*Rule) + func (e *Engine) ClearRules() + func (e *Engine) GenerateResponse() *EngineResponse + func (e *Engine) GetRules() []*Rule + func (e *Engine) HandleEvent(eventName string, ruleName string, result bool, almanac *Almanac, ...) error + func (e *Engine) ReduceResults() map[string]bool + func (e *Engine) RegisterEvent(event Event) + func (e *Engine) RegisterEvents(events ...Event) + func (e *Engine) Results() map[string]*RuleResult + func (e *Engine) Run(almanac *Almanac) (*Engine, error) + func (e *Engine) SetEventHandler(handler EventHandler) + func (e *Engine) SetRules(rules []*Rule) + type EngineOption func(*Engine) + func WithAuditTrace() EngineOption + func WithConditionCaching() EngineOption + func WithMetrics(collector MetricsCollector) EngineOption + func WithParallelExecution(workers int) EngineOption + func WithPrioritySorting(o *SortRule) EngineOption + func WithSmartSkip() EngineOption + func WithoutAuditTrace() EngineOption + func WithoutConditionCaching() EngineOption + func WithoutParallelExecution() EngineOption + func WithoutPrioritySorting() EngineOption + type EngineResponse struct + Decision string + Events []EventResponse + Metadata map[string]interface{} + Reason interface{} + type EqualOperator struct + func (o *EqualOperator) Evaluate(factValue interface{}, compareValue interface{}) (bool, error) + type ErrorType string + const ErrAlmanac + const ErrCondition + const ErrEngine + const ErrEvent + const ErrFact + const ErrJSON + const ErrLoader + const ErrOperator + const ErrRule + type Event struct + Action func(EventContext) error + Mode EventMode + Name string + Params map[string]interface{} + type EventContext struct + Almanac *Almanac + Params map[string]interface{} + Result bool + RuleName string + Timestamp time.Time + type EventHandler interface + Handle func(event Event, ctx EventContext) error + type EventMode int + const EventModeAsync + const EventModeSync + type EventOutcome string + const EventOutcomeFailure + const EventOutcomeSuccess + type EventResponse struct + Params map[string]interface{} + Type string + type Fact struct + func NewFact(id FactID, valueOrMethod interface{}, opts ...FactOption) Fact + func (f *Fact) Calculate(params map[string]interface{}) interface{} + func (f *Fact) FactType() string + func (f *Fact) GetCacheKey() (string, error) + func (f *Fact) GetOption(key string) (interface{}, bool) + func (f *Fact) HasOption(key string) bool + func (f *Fact) ID() FactID + func (f *Fact) IsDynamic() bool + func (f *Fact) Metadata() map[string]interface{} + func (f *Fact) ValueOrMethod() interface{} + type FactError struct + Err error + Fact Fact + func (e *FactError) Error() string + func (e *FactError) Unwrap() error + type FactID string + type FactOption func(*Fact) + func WithCache() FactOption + func WithMetadata(metadata map[string]interface{}) FactOption + func WithPriority(priority int) FactOption + func WithoutCache() FactOption + type GreaterThanInclusiveOperator struct + func (o *GreaterThanInclusiveOperator) Evaluate(factValue interface{}, compareValue interface{}) (bool, error) + type GreaterThanOperator struct + func (o *GreaterThanOperator) Evaluate(factValue interface{}, compareValue interface{}) (bool, error) + type HTTPRuleProvider struct + Client *http.Client + ETag string + LastUpdate time.Time + URL string + func NewHTTPRuleProvider(url string) *HTTPRuleProvider + func (p *HTTPRuleProvider) FetchRules(ctx context.Context) ([]*Rule, error) + type HotReloader struct + func NewHotReloader(engine *Engine, provider RuleProvider, interval time.Duration) *HotReloader + func (h *HotReloader) OnError(callback func(error)) + func (h *HotReloader) OnUpdate(callback func([]*Rule)) + func (h *HotReloader) Start(ctx context.Context) + func (h *HotReloader) Stop() + type InOperator struct + func (o *InOperator) Evaluate(factValue interface{}, compareValue interface{}) (bool, error) + type LessThanInclusiveOperator struct + func (o *LessThanInclusiveOperator) Evaluate(factValue interface{}, compareValue interface{}) (bool, error) + type LessThanOperator struct + func (o *LessThanOperator) Evaluate(factValue interface{}, compareValue interface{}) (bool, error) + type MetricsCollector interface + ObserveEngineRun func(ruleCount int, duration time.Duration) + ObserveEventExecution func(eventName string, ruleName string, result bool, duration time.Duration) + ObserveRuleEvaluation func(ruleName string, result bool, duration time.Duration) + type NotContainsOperator struct + func (o *NotContainsOperator) Evaluate(factValue interface{}, compareValue interface{}) (bool, error) + type NotEqualOperator struct + func (o *NotEqualOperator) Evaluate(factValue interface{}, compareValue interface{}) (bool, error) + type NotInOperator struct + func (o *NotInOperator) Evaluate(factValue interface{}, compareValue interface{}) (bool, error) + type Operator interface + Evaluate func(factValue interface{}, compareValue interface{}) (bool, error) + func GetOperator(opType OperatorType) (Operator, error) + type OperatorError struct + CompareValue interface{} + Err error + Operator OperatorType + Value interface{} + func (e *OperatorError) Error() string + func (e *OperatorError) Unwrap() error + type OperatorType string + const OperatorContains + const OperatorEqual + const OperatorGreaterThan + const OperatorGreaterThanInclusive + const OperatorIn + const OperatorLessThan + const OperatorLessThanInclusive + const OperatorNotContains + const OperatorNotEqual + const OperatorNotIn + const OperatorRegex + type PathResolver func(value interface{}, path string) (interface{}, error) + type RegexOperator struct + func (o *RegexOperator) Evaluate(factValue interface{}, compareValue interface{}) (bool, error) + type Rule struct + Conditions ConditionSet + Name string + OnFailure []RuleEvent + OnSuccess []RuleEvent + Priority int + Result bool + func (r *Rule) Compile() error + func (r *Rule) GetRequiredFacts() []FactID + type RuleBuilder struct + func NewRuleBuilder() *RuleBuilder + func (rb *RuleBuilder) Build() *Rule + func (rb *RuleBuilder) WithConditions(node ConditionNode) *RuleBuilder + func (rb *RuleBuilder) WithName(name string) *RuleBuilder + func (rb *RuleBuilder) WithOnFailure(eventNames ...string) *RuleBuilder + func (rb *RuleBuilder) WithOnFailureEvent(event RuleEvent) *RuleBuilder + func (rb *RuleBuilder) WithOnSuccess(eventNames ...string) *RuleBuilder + func (rb *RuleBuilder) WithOnSuccessEvent(event RuleEvent) *RuleBuilder + func (rb *RuleBuilder) WithPriority(priority int) *RuleBuilder + type RuleEngineError struct + Err error + Msg string + Type ErrorType + func (e *RuleEngineError) Error() string + func (e *RuleEngineError) Unwrap() error + type RuleError struct + Err error + Rule Rule + func (e *RuleError) Error() string + func (e *RuleError) Unwrap() error + type RuleEvent struct + Name string + Params map[string]interface{} + func (re *RuleEvent) UnmarshalJSON(data []byte) error + type RuleProvider interface + FetchRules func(ctx context.Context) ([]*Rule, error) + type RuleResult struct + Conditions *ConditionSetResult + Name string + OnFailure []RuleEvent + OnSuccess []RuleEvent + Priority int + Result bool + type SortRule int Other modules containing this package github.com/deadelus/go-rules-engine