From 7fb4d9039ad14b7aa88029bf7ad61b146cba761e Mon Sep 17 00:00:00 2001 From: James Dong Date: Sat, 10 Oct 2020 05:01:56 +0000 Subject: [PATCH] Fix an issue caused by recent reverted interface-based service registration in cmd/protoc-gen-go-grpc. --- demos/golang/grpc_pingpong/go.mod | 3 ++- demos/golang/grpc_pingpong/pong.go | 10 +++++++--- 2 files changed, 9 insertions(+), 4 deletions(-) diff --git a/demos/golang/grpc_pingpong/go.mod b/demos/golang/grpc_pingpong/go.mod index 13f0f118..a41a4079 100644 --- a/demos/golang/grpc_pingpong/go.mod +++ b/demos/golang/grpc_pingpong/go.mod @@ -4,6 +4,7 @@ go 1.13 require ( github.com/golang/protobuf v1.4.1 - google.golang.org/grpc v1.33.0-dev + google.golang.org/grpc v1.34.0-dev + google.golang.org/grpc/cmd/protoc-gen-go-grpc v1.0.0 google.golang.org/protobuf v1.25.0 ) diff --git a/demos/golang/grpc_pingpong/pong.go b/demos/golang/grpc_pingpong/pong.go index f5d09109..1d6edd17 100644 --- a/demos/golang/grpc_pingpong/pong.go +++ b/demos/golang/grpc_pingpong/pong.go @@ -11,13 +11,17 @@ import ( "grpc_pingpong/github.com/occlum/demos/grpc_pingpong/pingpong" ) -func PingPong(ctx context.Context, in *pingpong.PingPongMesg) (*pingpong.PingPongMesg, error) { +type PingPongServer struct { + pingpong.UnimplementedPingPongServiceServer +} + +func (s *PingPongServer) PingPong(ctx context.Context, in *pingpong.PingPongMesg) (*pingpong.PingPongMesg, error) { currentTime := time.Now() fmt.Printf("Receiving Ping: %s (at %s)\n", in.Ping, currentTime.Format("2006-01-02T15:04:05.999999999Z07:00")) return &pingpong.PingPongMesg{Ping: in.Ping, Pong: fmt.Sprintf("Greetings from Pong! Ping Echoed: %s", in.Ping), Timestamp: currentTime.Format("2006-01-02T15:04:05.999999999Z07:00")}, nil - } +} func main() { fmt.Println("grpc_pingpong server is waiting for service requests ...") @@ -29,7 +33,7 @@ func main() { grpcServer := grpc.NewServer() - pingpong.RegisterPingPongServiceService(grpcServer, &pingpong.PingPongServiceService{PingPong: PingPong}) + pingpong.RegisterPingPongServiceServer(grpcServer, &PingPongServer{}) if err := grpcServer.Serve(conn); err != nil { fmt.Printf("Failed to serve: %s\n", err)