Documentation ¶
Index ¶
- Variables
- type Engine
- func (e *Engine) NewRuntime(facts map[string]interface{}) *Runtime
- func (e *Engine) Run(target string, worker int) (interface{}, []error)
- func (e *Engine) RunDefault() (interface{}, []error)
- func (e *Engine) RunWithCustomTarget(target string) (interface{}, []error)
- func (e *Engine) Set(facts map[string]interface{}, rules []Rule, ...) error
- func (e *Engine) SetFacts(facts map[string]interface{}) error
- func (e *Engine) SetRuleFunctions(ruleFunctions map[string]RuleFunction) error
- func (e *Engine) SetRules(rules []Rule) error
- type EvalResult
- type Job
- type Rule
- type RuleFunction
- type Runtime
Constants ¶
This section is empty.
Variables ¶
var ( //DefaultTarget is the default target facts DefaultTarget = "result_end" // DefaultWorker is the default worker for Engine DefaultWorker = 0 // DefaultRuleLength ... DefaultRuleLength = 100 )
Functions ¶
This section is empty.
Types ¶
type Engine ¶
type Engine struct { InitialFacts map[string]interface{} Rules []Rule RuleFunctions map[string]govaluate.ExpressionFunction RuleCache *cache.Cache RunLock sync.RWMutex RuntimePool *pool.ReferenceCountedPool }
Engine core of the machine
func NewWithCustomWorkerSize ¶ added in v0.6.0
NewWithCustomWorkerSize ...
func (*Engine) NewRuntime ¶ added in v0.6.0
NewRuntime ...
func (*Engine) Run ¶
Run will execute rule and facts to get the result DEPRICATION NOTICE : worker param is depricated since it has been moved to engine struct
func (*Engine) RunDefault ¶ added in v0.5.0
RunDefault will execute run with default parameneter
func (*Engine) RunWithCustomTarget ¶ added in v0.6.0
RunWithCustomTarget will execute run using customizable end target
func (*Engine) Set ¶ added in v0.5.0
func (e *Engine) Set(facts map[string]interface{}, rules []Rule, ruleFunction map[string]RuleFunction) error
Set all of engine attibutes in one single function
func (*Engine) SetFacts ¶ added in v0.4.0
SetFacts will set current engine with initial facts (replace the old one)
func (*Engine) SetRuleFunctions ¶ added in v0.5.0
func (e *Engine) SetRuleFunctions(ruleFunctions map[string]RuleFunction) error
SetRuleFunctions will set current engine with Expression Functions
type EvalResult ¶ added in v0.5.0
EvalResult is evaluation Result
type Job ¶ added in v0.5.0
type Job struct { Output string ParsedExpression *govaluate.EvaluableExpression }
Job struct
type Rule ¶
type Rule struct { Input []string `json:"input"` Output string `json:"output"` Expression string `json:"expression"` }
Rule is struct for rule in fished
type RuleFunction ¶ added in v0.2.0
type RuleFunction func(...interface{}) (interface{}, error)
RuleFunction if type defined for rule function
type Runtime ¶ added in v0.5.0
type Runtime struct { pool.ReferenceCounter Facts map[string]interface{} JobCh chan *Job ResultCh chan *EvalResult UsedRule map[int]struct{} FactsMutex sync.RWMutex }
Runtime is an struct for each time Engine.Run() is called
func (*Runtime) Evaluate ¶ added in v0.5.0
func (r *Runtime) Evaluate(job *Job, result chan<- *EvalResult)
Evaluate will evaluate each job in runtime