Files
full/module/base/passport/internal/server/new.go

45 lines
1.0 KiB
Go
Raw Normal View History

// Code generated by protoc-gen-slc. DO NOT EDIT.
package server
import (
pb "bsm/full/module/base/passport/pb"
"context"
gwRuntime "github.com/grpc-ecosystem/grpc-gateway/v2/runtime"
"google.golang.org/grpc"
"google.golang.org/grpc/reflection"
)
type Server struct {
Grpc *grpc.Server
Ctx context.Context
Mux *gwRuntime.ServeMux
grpcConns map[string]*grpc.ClientConn // 连接池
}
func New(grpcServ *grpc.Server) *Server {
standalone := grpcServ == nil
if standalone {
grpcServ = grpc.NewServer()
}
srv := &Server{
Ctx: context.Background(),
Grpc: grpcServ,
grpcConns: make(map[string]*grpc.ClientConn),
}
// register service to grpc.Server
pb.RegisterAccountServer(srv.Grpc, NewAccountServer())
pb.RegisterForgetServer(srv.Grpc, NewForgetServer())
pb.RegisterLoginServer(srv.Grpc, NewLoginServer())
pb.RegisterRegisterServer(srv.Grpc, NewRegisterServer())
pb.RegisterVerifyServer(srv.Grpc, NewVerifyServer())
if standalone {
reflection.Register(srv.Grpc)
}
return srv
}