adding a register method to rpc.

This commit is contained in:
greg stone
2023-02-22 17:03:33 +00:00
parent cb12dfd173
commit 49acb9dc02
2 changed files with 8 additions and 9 deletions

View File

@@ -11,6 +11,7 @@ import (
"github.com/spf13/cobra"
"github.com/spf13/viper"
"github.com/tutorialedge/go-grpc-tutorial/chat"
"google.golang.org/grpc"
"os"
)
@@ -88,12 +89,12 @@ var seedCmd = &cobra.Command{
os.Exit(1)
}
// We need to enable specific gRPC services here
//srv := rpc.Server()
//helloworld.RegisterGreeterServer(srv, helloworld)
s := chat.Server{}
rpc.Register(func(srv *grpc.Server) {
chat.RegisterChatServiceServer(rpc.Server(), &s)
s := chat.Server{}
chat.RegisterChatServiceServer(srv, &s)
})
log.I.Ln("starting rpc server")

View File

@@ -64,8 +64,8 @@ func init() {
server = grpc.NewServer()
}
func Server() *grpc.Server {
return server
func Register(r func(srv *grpc.Server)) {
r(server)
}
func Start(ctx context.Context) {
@@ -115,8 +115,6 @@ func Start(ctx context.Context) {
go server.Serve(tcpSock)
//network.ListenPing(netstack.PingAddrFromAddr(deviceIP))
isReady <- true
select {