MCPcopy
hub / github.com/grpc/grpc-go / callUnaryEcho

Function callUnaryEcho

examples/features/metadata_interceptor/client/main.go:40–57  ·  view source on GitHub ↗
(ctx context.Context, client pb.EchoClient)

Source from the content-addressed store, hash-verified

38var addr = flag.String("addr", "localhost:50051", "the address to connect to")
39
40func callUnaryEcho(ctx context.Context, client pb.EchoClient) {
41 var header, trailer metadata.MD
42 resp, err := client.UnaryEcho(ctx, &pb.EchoRequest{Message: "hello world"}, grpc.Header(&header), grpc.Trailer(&trailer))
43 if err != nil {
44 log.Fatalf("UnaryEcho: %v", err)
45 }
46 fmt.Println("UnaryEcho: ", resp.Message)
47
48 fmt.Println("Received headers:")
49 for k, v := range header {
50 fmt.Printf("%s: %v\n", k, v)
51 }
52
53 fmt.Println("Received trailers:")
54 for k, v := range trailer {
55 fmt.Printf("%s: %v\n", k, v)
56 }
57}
58
59func callBidiStreamingEcho(ctx context.Context, client pb.EchoClient) {
60 c, err := client.BidirectionalStreamingEcho(ctx)

Callers 1

mainFunction · 0.70

Calls 6

HeaderFunction · 0.92
TrailerFunction · 0.92
PrintlnMethod · 0.80
UnaryEchoMethod · 0.65
FatalfMethod · 0.65
PrintfMethod · 0.65

Tested by

no test coverage detected