@@ -90,28 +90,28 @@ func (g *GruleEngine) Execute(dataCtx ast.IDataContext, knowledge *ast.Knowledge
9090}
9191
9292// notifyEvaluateRuleEntry will notify all registered listener that a rule is being evaluated.
93- func (g * GruleEngine ) notifyEvaluateRuleEntry (cycle uint64 , entry * ast.RuleEntry , candidate bool ) {
93+ func (g * GruleEngine ) notifyEvaluateRuleEntry (ctx context. Context , cycle uint64 , entry * ast.RuleEntry , candidate bool ) {
9494 if g .Listeners != nil && len (g .Listeners ) > 0 {
9595 for _ , gl := range g .Listeners {
96- gl .EvaluateRuleEntry (cycle , entry , candidate )
96+ gl .EvaluateRuleEntry (ctx , cycle , entry , candidate )
9797 }
9898 }
9999}
100100
101101// notifyEvaluateRuleEntry will notify all registered listener that a rule is being executed.
102- func (g * GruleEngine ) notifyExecuteRuleEntry (cycle uint64 , entry * ast.RuleEntry ) {
102+ func (g * GruleEngine ) notifyExecuteRuleEntry (ctx context. Context , cycle uint64 , entry * ast.RuleEntry ) {
103103 if g .Listeners != nil && len (g .Listeners ) > 0 {
104104 for _ , gl := range g .Listeners {
105- gl .ExecuteRuleEntry (cycle , entry )
105+ gl .ExecuteRuleEntry (ctx , cycle , entry )
106106 }
107107 }
108108}
109109
110110// notifyEvaluateRuleEntry will notify all registered listener that a rule is being executed.
111- func (g * GruleEngine ) notifyBeginCycle (cycle uint64 ) {
111+ func (g * GruleEngine ) notifyBeginCycle (ctx context. Context , cycle uint64 ) {
112112 if g .Listeners != nil && len (g .Listeners ) > 0 {
113113 for _ , gl := range g .Listeners {
114- gl .BeginCycle (cycle )
114+ gl .BeginCycle (ctx , cycle )
115115 }
116116 }
117117}
@@ -161,7 +161,7 @@ func (g *GruleEngine) ExecuteWithContext(ctx context.Context, dataCtx ast.IDataC
161161 return ctx .Err ()
162162 }
163163
164- g .notifyBeginCycle (cycle + 1 )
164+ g .notifyBeginCycle (ctx , cycle + 1 )
165165
166166 // Select all rule entry that can be executed.
167167 log .Tracef ("Select all rule entry that can be executed." )
@@ -187,7 +187,7 @@ func (g *GruleEngine) ExecuteWithContext(ctx context.Context, dataCtx ast.IDataC
187187 runnable = append (runnable , ruleEntry )
188188 }
189189 // notify all listeners that a rule's when scope is been evaluated.
190- g .notifyEvaluateRuleEntry (cycle + 1 , ruleEntry , can )
190+ g .notifyEvaluateRuleEntry (ctx , cycle + 1 , ruleEntry , can )
191191 }
192192 }
193193
@@ -221,7 +221,7 @@ func (g *GruleEngine) ExecuteWithContext(ctx context.Context, dataCtx ast.IDataC
221221 // set the current rule entry to run. This is for trace ability purpose
222222 dataCtx .SetRuleEntry (runner )
223223 // notify listeners that we are about to execute a rule entry then scope
224- g .notifyExecuteRuleEntry (cycle , runner )
224+ g .notifyExecuteRuleEntry (ctx , cycle , runner )
225225 // execute the top most prioritized rule
226226 err := runner .Execute (ctx , dataCtx , knowledge .WorkingMemory )
227227 if err != nil {
0 commit comments