feat kafka

This commit is contained in:
2026-01-23 21:26:08 +08:00
parent f80167df85
commit 6c124f9f3f
9 changed files with 201 additions and 21 deletions

View File

@@ -21,8 +21,9 @@ func (p *Program) Init(_ svc.Environment) error {
return err
}
p.moduleList = append(p.moduleList, base)
p.moduleList = append(p.moduleList, (&module.DB{}).Bind(config.Get().DB))
p.moduleList = append(p.moduleList, (&module.DB{}).Bind(config.Get().DB, common.KeyDiscoverServiceNameQgdzs))
p.moduleList = append(p.moduleList, (&module.Grpc{}).Bind(grpc_server.NewServer(config.Get().Serve.Grpc)))
p.moduleList = append(p.moduleList, &ModuleTimer{})
p.moduleList = append(p.moduleList, (&module.Prometheus{}).Bind(config.Get().Metric))
p.moduleList = append(p.moduleList, (&module.Tracer{}).Bind(config.Get().Metric, common.KeyDiscoverServiceNameQgdzs))
p.moduleList = append(p.moduleList, &module.Discover{})

29
app/timer.go Normal file
View File

@@ -0,0 +1,29 @@
package app
import (
"git.hlsq.asia/mmorpg/service-common/module"
"git.hlsq.asia/mmorpg/service-qgdzs/internal/timer"
"sync"
)
// ModuleTimer 定时器模块
type ModuleTimer struct {
module.DefaultModule
timer *timer.Timer
}
func (m *ModuleTimer) Init() error {
m.timer = &timer.Timer{}
return nil
}
func (m *ModuleTimer) Start(ready *sync.WaitGroup) error {
m.timer.Start()
ready.Done()
return nil
}
func (m *ModuleTimer) Stop() error {
m.timer.Stop()
return nil
}