feat 废弃jwt 、 学识分

This commit is contained in:
2026-02-06 22:31:29 +08:00
parent b1dfb88f71
commit 456f1970eb
17 changed files with 236 additions and 156 deletions

View File

@@ -17,11 +17,10 @@ type Program struct {
}
func (p *Program) Init(_ svc.Environment) error {
base := &ModuleBase{}
if err := base.Init(); err != nil {
if err := config.LoadConfig(); err != nil {
return err
}
p.moduleList = append(p.moduleList, base)
p.moduleList = append(p.moduleList, (&module.Base{}).Bind(config.Get().Log))
p.moduleList = append(p.moduleList, (&module.DB{}).Bind(config.Get().DB, config.Get().App.Name))
p.moduleList = append(p.moduleList, &ModuleWebServer{})
p.moduleList = append(p.moduleList, &ModuleWebsocketServer{})
@@ -31,10 +30,7 @@ func (p *Program) Init(_ svc.Environment) error {
p.moduleList = append(p.moduleList, (&module.Tracer{}).Bind(config.Get().Metric, common.KeyDiscoverServiceNameGateway))
p.moduleList = append(p.moduleList, &module.Discover{})
for i, m := range p.moduleList {
if i == 0 {
continue
}
for _, m := range p.moduleList {
if err := m.Init(); err != nil {
return err
}

View File

@@ -1,27 +0,0 @@
package app
import (
"git.hlsq.asia/mmorpg/service-common/log"
"git.hlsq.asia/mmorpg/service-common/module"
"git.hlsq.asia/mmorpg/service-common/utils"
"git.hlsq.asia/mmorpg/service-gateway/config"
"math/rand"
)
// ModuleBase 基础模块,或者一些零散的模块
type ModuleBase struct {
module.DefaultModule
}
func (m *ModuleBase) Init() error {
// 配置
if err := config.LoadConfig(); err != nil {
return err
}
cfg := config.Get()
// 日志
log.Init(cfg.Log.Debug, cfg.Log.MaxSize, cfg.Log.MaxBackups, cfg.Log.MaxAge, cfg.Log.Level)
// 雪花
utils.InitSnowflake(int64(rand.Intn(1000)))
return nil
}