feat 废弃jwt 、 学识分

This commit is contained in:
2026-02-06 22:31:33 +08:00
parent e2fa47fd27
commit 9b3a23e9be
4 changed files with 6 additions and 37 deletions

View File

@@ -16,21 +16,17 @@ 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, (&module.Grpc{}).Bind(grpc_server.NewServer(config.Get().Serve.Grpc)))
p.moduleList = append(p.moduleList, (&module.Prometheus{}).Bind(config.Get().Metric))
p.moduleList = append(p.moduleList, (&module.Tracer{}).Bind(config.Get().Metric, common.KeyDiscoverServiceNameUser))
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-user/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
}