refactor: move event system to reducer, remove engine package
Move the event emitter and lifecycle events from the engine into the reducer, making the reducer the single point of orchestration for reduction. This eliminates the engine package entirely. - Add events.go to pkg/reducer with Start, Step, and Stop events. - Extend Reducer interface to embed Emitter and add Expression() method. - Update NormalOrderReducer to embed BaseEmitter and emit lifecycle events. - Update all plugins to attach to Reducer instead of Engine. - Remove internal/engine package. - Add Off() method to BaseEmitter to complete Emitter interface. - Fix Emitter.On signature to use generic type E instead of string.
This commit is contained in:
@@ -5,8 +5,8 @@ import (
|
||||
"os"
|
||||
"time"
|
||||
|
||||
"git.maximhutz.com/max/lambda/internal/engine"
|
||||
"git.maximhutz.com/max/lambda/internal/statistics"
|
||||
"git.maximhutz.com/max/lambda/pkg/reducer"
|
||||
)
|
||||
|
||||
// An observer, to track reduction performance.
|
||||
@@ -16,11 +16,11 @@ type Statistics struct {
|
||||
}
|
||||
|
||||
// Create a new reduction performance Statistics.
|
||||
func NewStatistics(process *engine.Engine) *Statistics {
|
||||
func NewStatistics(r reducer.Reducer) *Statistics {
|
||||
plugin := &Statistics{}
|
||||
process.On(engine.StartEvent, plugin.Start)
|
||||
process.On(engine.StepEvent, plugin.Step)
|
||||
process.On(engine.StopEvent, plugin.Stop)
|
||||
r.On(reducer.StartEvent, plugin.Start)
|
||||
r.On(reducer.StepEvent, plugin.Step)
|
||||
r.On(reducer.StopEvent, plugin.Stop)
|
||||
|
||||
return plugin
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user