()
| 36 | var addr = flag.String("addr", "localhost:50051", "the address to connect to") |
| 37 | |
| 38 | func main() { |
| 39 | flag.Parse() |
| 40 | |
| 41 | // Set up a connection to the server. |
| 42 | conn, err := grpc.NewClient(*addr, grpc.WithTransportCredentials(insecure.NewCredentials())) |
| 43 | if err != nil { |
| 44 | log.Fatalf("did not connect: %v", err) |
| 45 | } |
| 46 | defer conn.Close() |
| 47 | |
| 48 | c := pb.NewEchoClient(conn) |
| 49 | |
| 50 | // Send the RPC compressed. If all RPCs on a client should be sent this |
| 51 | // way, use the DialOption: |
| 52 | // grpc.WithDefaultCallOptions(grpc.UseCompressor(gzip.Name)) |
| 53 | const msg = "compress" |
| 54 | ctx, cancel := context.WithTimeout(context.Background(), 10*time.Second) |
| 55 | defer cancel() |
| 56 | res, err := c.UnaryEcho(ctx, &pb.EchoRequest{Message: msg}, grpc.UseCompressor(gzip.Name)) |
| 57 | fmt.Printf("UnaryEcho call returned %q, %v\n", res.GetMessage(), err) |
| 58 | if err != nil || res.GetMessage() != msg { |
| 59 | log.Fatalf("Message=%q, err=%v; want Message=%q, err=<nil>", res.GetMessage(), err, msg) |
| 60 | } |
| 61 | |
| 62 | } |
nothing calls this directly
no test coverage detected