@@ -7,8 +7,12 @@ guidelines.
7
7
8
8
A [ ClientConn] [ client-conn ] can safely be accessed concurrently. Using
9
9
[ helloworld] [ helloworld ] as an example, one could share the ` ClientConn ` across
10
- multiple goroutines to create multiple ` GreeterClient ` types. In this case, RPCs
11
- would be sent in parallel.
10
+ multiple goroutines to create multiple ` GreeterClient ` types. In this case,
11
+ RPCs would be sent in parallel. ` GreeterClient ` , generated from the proto
12
+ definitions and wrapping ` ClientConn ` , is also concurrency safe, and may be
13
+ directly shared in the same way. Note that, as illustrated in
14
+ [ the multiplex example] [ multiplex-example ] , other ` Client ` types may share a
15
+ single ` ClientConn ` as well.
12
16
13
17
## Streams
14
18
@@ -24,10 +28,12 @@ call `RecvMsg` on the same stream in different goroutines.
24
28
Each RPC handler attached to a registered server will be invoked in its own
25
29
goroutine. For example, [ SayHello] [ say-hello ] will be invoked in its own
26
30
goroutine. The same is true for service handlers for streaming RPCs, as seen
27
- in the route guide example [ here] [ route-guide-stream ] .
31
+ in the route guide example [ here] [ route-guide-stream ] . Similar to clients,
32
+ multiple services can be registered to the same server.
28
33
29
34
[ helloworld ] : https://github.com/grpc/grpc-go/blob/master/examples/helloworld/greeter_client/main.go#L43
30
35
[ client-conn ] : https://godoc.org/google.golang.org/grpc#ClientConn
31
36
[ stream ] : https://godoc.org/google.golang.org/grpc#Stream
32
37
[ say-hello ] : https://github.com/grpc/grpc-go/blob/master/examples/helloworld/greeter_server/main.go#L41
33
38
[ route-guide-stream ] : https://github.com/grpc/grpc-go/blob/master/examples/route_guide/server/server.go#L126
39
+ [ multiplex-example ] : https://github.com/grpc/grpc-go/tree/master/examples/features/multiplex
0 commit comments