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