Files
service-qgdzs/internal/grpc_server/server_init.go

44 lines
1.0 KiB
Go

package grpc_server
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/grpc_pb"
"git.hlsq.asia/mmorpg/service-qgdzs/internal/dao/query"
"git.hlsq.asia/mmorpg/service-qgdzs/internal/dao/repository"
"google.golang.org/grpc"
)
type Server struct {
grpc_pb.UnimplementedQgdzsServer
service.Base
query *query.Query
}
func NewServer(cfg *config.GrpcConfig) *Server {
s := &Server{
Base: service.Base{
Target: common.KeyDiscoverQgdzs,
ServiceName: common.KeyDiscoverServiceNameQgdzs,
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) {
grpc_pb.RegisterQgdzsServer(serve, s)
s.query = repository.Query()
}
func (s *Server) OnClose() {
}