Skip to content

Commit e2d4ecf

Browse files
authored
doc: clarify client concurrency (grpc#3001)
1 parent 59c5eb7 commit e2d4ecf

File tree

1 file changed

+9
-3
lines changed

1 file changed

+9
-3
lines changed

Documentation/concurrency.md

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,12 @@ guidelines.
77

88
A [ClientConn][client-conn] can safely be accessed concurrently. Using
99
[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.
1216

1317
## Streams
1418

@@ -24,10 +28,12 @@ call `RecvMsg` on the same stream in different goroutines.
2428
Each RPC handler attached to a registered server will be invoked in its own
2529
goroutine. For example, [SayHello][say-hello] will be invoked in its own
2630
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.
2833

2934
[helloworld]: https://github.com/grpc/grpc-go/blob/master/examples/helloworld/greeter_client/main.go#L43
3035
[client-conn]: https://godoc.org/google.golang.org/grpc#ClientConn
3136
[stream]: https://godoc.org/google.golang.org/grpc#Stream
3237
[say-hello]: https://github.com/grpc/grpc-go/blob/master/examples/helloworld/greeter_server/main.go#L41
3338
[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

Comments
 (0)