mirror of
https://github.com/jwetzell/showbridge-go.git
synced 2026-04-27 05:15:47 +00:00
move router to module New func
This commit is contained in:
@@ -18,7 +18,7 @@ type Interval struct {
|
||||
func init() {
|
||||
RegisterModule(ModuleRegistration{
|
||||
Type: "gen.interval",
|
||||
New: func(config config.ModuleConfig) (Module, error) {
|
||||
New: func(config config.ModuleConfig, router *Router) (Module, error) {
|
||||
params := config.Params
|
||||
|
||||
duration, ok := params["duration"]
|
||||
@@ -32,7 +32,7 @@ func init() {
|
||||
return nil, fmt.Errorf("gen.interval duration must be number")
|
||||
}
|
||||
|
||||
return &Interval{Duration: uint32(durationNum), config: config}, nil
|
||||
return &Interval{Duration: uint32(durationNum), config: config, router: router}, nil
|
||||
},
|
||||
})
|
||||
}
|
||||
@@ -45,10 +45,6 @@ func (i *Interval) Type() string {
|
||||
return i.config.Type
|
||||
}
|
||||
|
||||
func (i *Interval) RegisterRouter(router *Router) {
|
||||
i.router = router
|
||||
}
|
||||
|
||||
func (i *Interval) Run() error {
|
||||
ticker := time.NewTicker(time.Millisecond * time.Duration(i.Duration))
|
||||
i.ticker = ticker
|
||||
|
||||
Reference in New Issue
Block a user