feat 废弃jwt 、 学识分
This commit is contained in:
10
app/app.go
10
app/app.go
@@ -16,11 +16,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, (&module.Grpc{}).Bind(grpc_server.NewServer(config.Get().Serve.Grpc)))
|
||||
p.moduleList = append(p.moduleList, &ModuleTimer{})
|
||||
@@ -28,10 +27,7 @@ func (p *Program) Init(_ svc.Environment) error {
|
||||
p.moduleList = append(p.moduleList, (&module.Tracer{}).Bind(config.Get().Metric, common.KeyDiscoverServiceNameQgdzs))
|
||||
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
|
||||
}
|
||||
|
||||
27
app/base.go
27
app/base.go
@@ -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-qgdzs/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
|
||||
}
|
||||
Reference in New Issue
Block a user