@@ -90,28 +90,28 @@ func (g *GruleEngine) Execute(dataCtx ast.IDataContext, knowledge *ast.Knowledge
90
90
}
91
91
92
92
// 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 ) {
94
94
if g .Listeners != nil && len (g .Listeners ) > 0 {
95
95
for _ , gl := range g .Listeners {
96
- gl .EvaluateRuleEntry (cycle , entry , candidate )
96
+ gl .EvaluateRuleEntry (ctx , cycle , entry , candidate )
97
97
}
98
98
}
99
99
}
100
100
101
101
// 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 ) {
103
103
if g .Listeners != nil && len (g .Listeners ) > 0 {
104
104
for _ , gl := range g .Listeners {
105
- gl .ExecuteRuleEntry (cycle , entry )
105
+ gl .ExecuteRuleEntry (ctx , cycle , entry )
106
106
}
107
107
}
108
108
}
109
109
110
110
// 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 ) {
112
112
if g .Listeners != nil && len (g .Listeners ) > 0 {
113
113
for _ , gl := range g .Listeners {
114
- gl .BeginCycle (cycle )
114
+ gl .BeginCycle (ctx , cycle )
115
115
}
116
116
}
117
117
}
@@ -161,7 +161,7 @@ func (g *GruleEngine) ExecuteWithContext(ctx context.Context, dataCtx ast.IDataC
161
161
return ctx .Err ()
162
162
}
163
163
164
- g .notifyBeginCycle (cycle + 1 )
164
+ g .notifyBeginCycle (ctx , cycle + 1 )
165
165
166
166
// Select all rule entry that can be executed.
167
167
log .Tracef ("Select all rule entry that can be executed." )
@@ -187,7 +187,7 @@ func (g *GruleEngine) ExecuteWithContext(ctx context.Context, dataCtx ast.IDataC
187
187
runnable = append (runnable , ruleEntry )
188
188
}
189
189
// 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 )
191
191
}
192
192
}
193
193
@@ -221,7 +221,7 @@ func (g *GruleEngine) ExecuteWithContext(ctx context.Context, dataCtx ast.IDataC
221
221
// set the current rule entry to run. This is for trace ability purpose
222
222
dataCtx .SetRuleEntry (runner )
223
223
// notify listeners that we are about to execute a rule entry then scope
224
- g .notifyExecuteRuleEntry (cycle , runner )
224
+ g .notifyExecuteRuleEntry (ctx , cycle , runner )
225
225
// execute the top most prioritized rule
226
226
err := runner .Execute (ctx , dataCtx , knowledge .WorkingMemory )
227
227
if err != nil {
0 commit comments