feat grpc模块

This commit is contained in:
2026-01-19 10:53:12 +08:00
parent 73d3361f34
commit 5aeff7c786
3 changed files with 5 additions and 35 deletions

View File

@@ -6,6 +6,7 @@ import (
"git.hlsq.asia/mmorpg/service-common/log"
"git.hlsq.asia/mmorpg/service-common/module"
"git.hlsq.asia/mmorpg/service-gateway/config"
"git.hlsq.asia/mmorpg/service-gateway/internal/grpc_server"
"github.com/judwhite/go-svc"
)
@@ -22,7 +23,7 @@ func (p *Program) Init(_ svc.Environment) error {
p.moduleList = append(p.moduleList, (&module.DB{}).Bind(config.Get().DB))
p.moduleList = append(p.moduleList, &ModuleWebServer{})
p.moduleList = append(p.moduleList, &ModuleWebsocketServer{})
p.moduleList = append(p.moduleList, &ModuleGrpcServer{})
p.moduleList = append(p.moduleList, (&module.Grpc{}).Bind(grpc_server.NewServer(config.Get().Serve.Grpc)))
p.moduleList = append(p.moduleList, &ModuleLoginQueue{})
p.moduleList = append(p.moduleList, (&module.Prometheus{}).Bind(config.Get().Metric))
p.moduleList = append(p.moduleList, (&module.Tracer{}).Bind(config.Get().Metric, common.KeyDiscoverServiceNameGateway))

View File

@@ -1,32 +0,0 @@
package app
import (
"git.hlsq.asia/mmorpg/service-common/module"
"git.hlsq.asia/mmorpg/service-common/net/grpc/service"
"git.hlsq.asia/mmorpg/service-gateway/config"
"git.hlsq.asia/mmorpg/service-gateway/internal/grpc_server"
)
// ModuleGrpcServer Grpc服务模块
type ModuleGrpcServer struct {
server service.IService
}
func (m *ModuleGrpcServer) Init() error {
return nil
}
func (m *ModuleGrpcServer) Start() error {
m.server = grpc_server.NewServer(config.Get().Serve.Grpc.TTL)
m.server.Init(config.Get().Serve.Grpc.Address, config.Get().Serve.Grpc.Port)
return nil
}
func (m *ModuleGrpcServer) Stop() error {
m.server.Close()
return nil
}
func (m *ModuleGrpcServer) Bind(_ ...any) module.Module {
return m
}