feat 服务发现模块
This commit is contained in:
@@ -2,7 +2,6 @@ package app
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"git.hlsq.asia/mmorpg/service-common/discover"
|
||||
"git.hlsq.asia/mmorpg/service-common/discover/common"
|
||||
"git.hlsq.asia/mmorpg/service-common/log"
|
||||
"git.hlsq.asia/mmorpg/service-common/module"
|
||||
@@ -24,6 +23,7 @@ func (p *Program) Init(_ svc.Environment) error {
|
||||
p.moduleList = append(p.moduleList, &ModuleGrpcServer{})
|
||||
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{})
|
||||
|
||||
for i, m := range p.moduleList {
|
||||
if i == 0 {
|
||||
@@ -43,14 +43,12 @@ func (p *Program) Start() error {
|
||||
return err
|
||||
}
|
||||
}
|
||||
discover.Listen()
|
||||
|
||||
log.Infof(fmt.Sprintf("%v Start successful...", config.Get().App.Name))
|
||||
return nil
|
||||
}
|
||||
|
||||
func (p *Program) Stop() error {
|
||||
discover.Close()
|
||||
for i := len(p.moduleList) - 1; i >= 0; i-- {
|
||||
m := p.moduleList[i]
|
||||
if err := m.Stop(); err != nil {
|
||||
|
||||
2
go.mod
2
go.mod
@@ -3,7 +3,7 @@ module git.hlsq.asia/mmorpg/service-qgdzs
|
||||
go 1.24.0
|
||||
|
||||
require (
|
||||
git.hlsq.asia/mmorpg/service-common v0.0.0-20260116155014-3de703eb83c5
|
||||
git.hlsq.asia/mmorpg/service-common v0.0.0-20260117160658-22d48542a852
|
||||
github.com/judwhite/go-svc v1.2.1
|
||||
google.golang.org/grpc v1.77.0
|
||||
gorm.io/gen v0.3.27
|
||||
|
||||
4
go.sum
4
go.sum
@@ -1,7 +1,7 @@
|
||||
filippo.io/edwards25519 v1.1.0 h1:FNf4tywRC1HmFuKW5xopWpigGjJKiJSV0Cqo0cJWDaA=
|
||||
filippo.io/edwards25519 v1.1.0/go.mod h1:BxyFTGdWcka3PhytdK4V28tE5sGfRvvvRV7EaN4VDT4=
|
||||
git.hlsq.asia/mmorpg/service-common v0.0.0-20260116155014-3de703eb83c5 h1:b7pTgEyYUKpHtAAt4ea/3EYfX0Y0lYwhjrgf3kTyn0w=
|
||||
git.hlsq.asia/mmorpg/service-common v0.0.0-20260116155014-3de703eb83c5/go.mod h1:Dazg+4woCv9Jk7jgT2qUSGWhZOXx/0WYfJO+FCUDyhw=
|
||||
git.hlsq.asia/mmorpg/service-common v0.0.0-20260117160658-22d48542a852 h1:ehZ54MgGL3CO7KKDPxybFabIXxiQud1TGMcKjrSTcnw=
|
||||
git.hlsq.asia/mmorpg/service-common v0.0.0-20260117160658-22d48542a852/go.mod h1:Dazg+4woCv9Jk7jgT2qUSGWhZOXx/0WYfJO+FCUDyhw=
|
||||
github.com/BurntSushi/toml v1.2.0 h1:Rt8g24XnyGTyglgET/PRUNlrUeu9F5L+7FilkXfZgs0=
|
||||
github.com/BurntSushi/toml v1.2.0/go.mod h1:CxXYINrC8qIiEnFrOxCa7Jy5BFHlXnUU2pbicEuybxQ=
|
||||
github.com/beorn7/perks v1.0.1 h1:VlbKKnNfV8bJzeqoa4cOKqO6bYr3WgKZxO8Z16+hsOM=
|
||||
|
||||
Reference in New Issue
Block a user