move router to module New func

This commit is contained in:
Joel Wetzell
2025-12-06 23:00:45 -06:00
parent 8d8347fc4d
commit 9a06949b5b
16 changed files with 30 additions and 93 deletions

View File

@@ -21,7 +21,7 @@ type TCPClient struct {
func init() {
RegisterModule(ModuleRegistration{
Type: "net.tcp.client",
New: func(config config.ModuleConfig) (Module, error) {
New: func(config config.ModuleConfig, router *Router) (Module, error) {
params := config.Params
host, ok := params["host"]
@@ -68,7 +68,7 @@ func init() {
return nil, err
}
return &TCPClient{framer: framer, Addr: addr, config: config}, nil
return &TCPClient{framer: framer, Addr: addr, config: config, router: router}, nil
},
})
}
@@ -81,10 +81,6 @@ func (tc *TCPClient) Type() string {
return tc.config.Type
}
func (tc *TCPClient) RegisterRouter(router *Router) {
tc.router = router
}
func (tc *TCPClient) Run() error {
// TODO(jwetzell): shutdown with router.Context properly