add Stop function to module

This commit is contained in:
Joel Wetzell
2026-02-07 09:53:38 -06:00
parent 8f5091cf9b
commit 33ecc94097
19 changed files with 156 additions and 18 deletions

View File

@@ -25,6 +25,7 @@ type MockCounterModule struct {
outputCount int
router route.RouteIO
logger *slog.Logger
cancel context.CancelFunc
}
func (mcm *MockCounterModule) Id() string {
@@ -43,7 +44,9 @@ func (mcm *MockCounterModule) Run(ctx context.Context) error {
return fmt.Errorf("mock.counter could not get router from context")
}
mcm.router = router
mcm.ctx = ctx
moduleContext, cancel := context.WithCancel(ctx)
mcm.ctx = moduleContext
mcm.cancel = cancel
<-mcm.ctx.Done()
return nil
}
@@ -52,6 +55,10 @@ func (mcm *MockCounterModule) Type() string {
return mcm.config.Type
}
func (mcm *MockCounterModule) Stop() {
mcm.cancel()
}
func init() {
module.RegisterModule(module.ModuleRegistration{
Type: "mock.counter",