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

Function main

examples/features/health/client/main.go:56–88  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

54}
55
56func main() {
57 flag.Parse()
58
59 r := manual.NewBuilderWithScheme("whatever")
60 r.InitialState(resolver.State{
61 Addresses: []resolver.Address{
62 {Addr: "localhost:50051"},
63 {Addr: "localhost:50052"},
64 },
65 })
66
67 address := fmt.Sprintf("%s:///unused", r.Scheme())
68
69 options := []grpc.DialOption{
70 grpc.WithTransportCredentials(insecure.NewCredentials()),
71 grpc.WithResolvers(r),
72 // google.golang.org/grpc/health must also be imported
73 grpc.WithDefaultServiceConfig(serviceConfig),
74 }
75
76 conn, err := grpc.NewClient(address, options...)
77 if err != nil {
78 log.Fatalf("grpc.NewClient(%q): %v", address, err)
79 }
80 defer conn.Close()
81
82 echoClient := pb.NewEchoClient(conn)
83
84 for {
85 callUnaryEcho(echoClient)
86 time.Sleep(time.Second)
87 }
88}

Callers

nothing calls this directly

Calls 12

NewBuilderWithSchemeFunction · 0.92
WithTransportCredentialsFunction · 0.92
NewCredentialsFunction · 0.92
WithResolversFunction · 0.92
WithDefaultServiceConfigFunction · 0.92
NewClientFunction · 0.92
InitialStateMethod · 0.80
callUnaryEchoFunction · 0.70
ParseMethod · 0.65
SchemeMethod · 0.65
FatalfMethod · 0.65
CloseMethod · 0.65

Tested by

no test coverage detected