Skip to content

Commit

Permalink
feat: fix compile errors
Browse files Browse the repository at this point in the history
  • Loading branch information
andrewshan committed Dec 26, 2021
1 parent b21a6a5 commit f669d33
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 6 deletions.
11 changes: 8 additions & 3 deletions test/client_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -54,15 +54,20 @@ func (s *clientTestingSuite) TearDownSuite(c *check.C) {
}

func (s *clientTestingSuite) TestClientCall(c *check.C) {
srv := polaris.NewServer(
polaris.WithServerApplication(serverSvc), polaris.WithServerNamespace(serverNamespace), polaris.WithTTL(2))
hello.RegisterHelloServer(srv.GRPCServer(), &helloServer{})
srv := grpc.NewServer()
hello.RegisterHelloServer(srv, &helloServer{})
listen, err := net.Listen("tcp", "0.0.0.0:0")
if err != nil {
log.Fatalf("Failed to listen: %v", err)
}
log.Printf("success to listen on %s\n", listen.Addr())
defer listen.Close()
pSrv, err := polaris.Register(srv, listen,
polaris.WithServerApplication(serverSvc), polaris.WithServerNamespace(serverNamespace), polaris.WithTTL(2))
if nil != err {
log.Fatal(err)
}
defer pSrv.Deregister()
go func() {
err = srv.Serve(listen)
if nil != err {
Expand Down
13 changes: 10 additions & 3 deletions test/server_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,8 @@ import (
"net"
"time"

"google.golang.org/grpc"

polaris "github.com/polarismesh/grpc-go-polaris"
"github.com/polarismesh/grpc-go-polaris/test/hello"
"github.com/polarismesh/grpc-go-polaris/test/mock"
Expand Down Expand Up @@ -67,16 +69,21 @@ func (t *helloServer) SayHello(ctx context.Context, request *hello.HelloRequest)
}

func (s *serverTestingSuite) TestRegister(c *check.C) {
srv := polaris.NewServer(
polaris.WithServerApplication(serverSvc), polaris.WithServerNamespace(serverNamespace), polaris.WithTTL(2))
hello.RegisterHelloServer(srv.GRPCServer(), &helloServer{})
srv := grpc.NewServer()
hello.RegisterHelloServer(srv, &helloServer{})
// 监听端口
address := "127.0.0.1:8988"
listen, err := net.Listen("tcp", address)
if err != nil {
log.Fatalf("Failed to addr %s: %v", address, err)
}
defer listen.Close()
pSrv, err := polaris.Register(srv, listen,
polaris.WithServerApplication(serverSvc), polaris.WithServerNamespace(serverNamespace), polaris.WithTTL(2))
if nil != err {
log.Fatal(err)
}
defer pSrv.Deregister()
go func() {
err = srv.Serve(listen)
if nil != err {
Expand Down

0 comments on commit f669d33

Please sign in to comment.