Documentation ¶
Index ¶
- func SetLogger(externalLog interface{})
- type GruleEngine
- func (g *GruleEngine) Execute(dataCtx ast.IDataContext, knowledge *ast.KnowledgeBase) error
- func (g *GruleEngine) ExecuteWithContext(ctx context.Context, dataCtx ast.IDataContext, knowledge *ast.KnowledgeBase) error
- func (g *GruleEngine) FetchMatchingRules(dataCtx ast.IDataContext, knowledge *ast.KnowledgeBase) ([]*ast.RuleEntry, error)
- type GruleEngineListener
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type GruleEngine ¶
type GruleEngine struct { MaxCycle uint64 ReturnErrOnFailedRuleEvaluation bool Listeners []GruleEngineListener }
GruleEngine is the engine structure. It has the Execute method to start the engine to work.
func NewGruleEngine ¶
func NewGruleEngine() *GruleEngine
NewGruleEngine will create new instance of GruleEngine struct. It will set the max cycle to 5000
func (*GruleEngine) Execute ¶
func (g *GruleEngine) Execute(dataCtx ast.IDataContext, knowledge *ast.KnowledgeBase) error
Execute function is the same as ExecuteWithContext(context.Background())
func (*GruleEngine) ExecuteWithContext ¶
func (g *GruleEngine) ExecuteWithContext(ctx context.Context, dataCtx ast.IDataContext, knowledge *ast.KnowledgeBase) error
ExecuteWithContext function will execute a knowledge evaluation and action against data context. The engine will evaluate context cancelation status in each cycle. The engine also do conflict resolution of which rule to execute.
func (*GruleEngine) FetchMatchingRules ¶
func (g *GruleEngine) FetchMatchingRules(dataCtx ast.IDataContext, knowledge *ast.KnowledgeBase) ([]*ast.RuleEntry, error)
FetchMatchingRules function is responsible to fetch all the rules that matches to a fact against all rule entries Returns []*ast.RuleEntry order by salience
type GruleEngineListener ¶
type GruleEngineListener interface { // EvaluateRuleEntry will be called by the engine if it evaluate a rule entry EvaluateRuleEntry(cycle uint64, entry *ast.RuleEntry, candidate bool) // ExecuteRuleEntry will be called by the engine if it execute a rule entry in a cycle ExecuteRuleEntry(cycle uint64, entry *ast.RuleEntry) // BeginCycle will be called by the engine every time it start a new evaluation cycle BeginCycle(cycle uint64) }
GruleEngineListener is an interface to be implemented by those who want to listen the Engine execution.