原理:
将 ServiceDes很 implement 服务存储在 grpc.Server 的Map中!
用法:
// Register Greeter on the server.hwpb.RegisterGreeterServer(s, &hwServer{})// Register RouteGuide on the same server.ecpb.RegisterEchoServer(s, &ecServer{})
调用方法:
fmt.Println("--- calling helloworld.Greeter/SayHello ---")// Make a greeter client and send an RPC.hwc := hwpb.NewGreeterClient(conn)callSayHello(hwc, "multiplex")fmt.Println()fmt.Println("--- calling routeguide.RouteGuide/GetFeature ---")// Make a routeguild client with the same ClientConn.rgc := ecpb.NewEchoClient(conn)callUnaryEcho(rgc, "this is examples/multiplex")
