feat 包命名规范
This commit is contained in:
41
internal/grpcserver/server_init.go
Normal file
41
internal/grpcserver/server_init.go
Normal file
@@ -0,0 +1,41 @@
|
||||
package grpcserver
|
||||
|
||||
import (
|
||||
"git.hlsq.asia/mmorpg/service-common/config"
|
||||
"git.hlsq.asia/mmorpg/service-common/discover/common"
|
||||
"git.hlsq.asia/mmorpg/service-common/net/grpc/service"
|
||||
"git.hlsq.asia/mmorpg/service-common/proto/rs/rspb"
|
||||
"git.hlsq.asia/mmorpg/service-gateway/internal/global"
|
||||
"google.golang.org/grpc"
|
||||
)
|
||||
|
||||
type Server struct {
|
||||
rspb.UnimplementedGatewayServer
|
||||
service.Base
|
||||
}
|
||||
|
||||
func NewServer(cfg *config.GrpcConfig) *Server {
|
||||
s := &Server{
|
||||
Base: service.Base{
|
||||
Target: common.KeyDiscoverGateway,
|
||||
ServiceName: common.KeyDiscoverServiceNameGateway,
|
||||
Cfg: cfg,
|
||||
},
|
||||
}
|
||||
s.Base.OnCustomGrpcServerOption = s.OnCustomGrpcServerOption
|
||||
s.Base.OnInit = s.OnInit
|
||||
s.Base.OnClose = s.OnClose
|
||||
return s
|
||||
}
|
||||
|
||||
func (s *Server) OnCustomGrpcServerOption() []grpc.ServerOption {
|
||||
return nil
|
||||
}
|
||||
|
||||
func (s *Server) OnInit(serve *grpc.Server) {
|
||||
global.GatewaySID = s.SID
|
||||
rspb.RegisterGatewayServer(serve, s)
|
||||
}
|
||||
|
||||
func (s *Server) OnClose() {
|
||||
}
|
||||
Reference in New Issue
Block a user