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

Function main

examples/features/keepalive/client/main.go:44–64  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

42}
43
44func main() {
45 flag.Parse()
46
47 conn, err := grpc.NewClient(*addr, grpc.WithTransportCredentials(insecure.NewCredentials()), grpc.WithKeepaliveParams(kacp))
48 if err != nil {
49 log.Fatalf("did not connect: %v", err)
50 }
51 defer conn.Close()
52
53 c := pb.NewEchoClient(conn)
54
55 ctx, cancel := context.WithTimeout(context.Background(), 3*time.Minute)
56 defer cancel()
57 fmt.Println("Performing unary request")
58 res, err := c.UnaryEcho(ctx, &pb.EchoRequest{Message: "keepalive demo"})
59 if err != nil {
60 log.Fatalf("unexpected error from UnaryEcho: %v", err)
61 }
62 fmt.Println("RPC response:", res)
63 select {} // Block forever; run with GODEBUG=http2debug=2 to observe ping frames and GOAWAYs due to idleness.
64}

Callers

nothing calls this directly

Calls 9

UnaryEchoMethod · 0.95
NewClientFunction · 0.92
WithTransportCredentialsFunction · 0.92
NewCredentialsFunction · 0.92
WithKeepaliveParamsFunction · 0.92
PrintlnMethod · 0.80
ParseMethod · 0.65
FatalfMethod · 0.65
CloseMethod · 0.65

Tested by

no test coverage detected