1
0
Fork 0
mirror of https://github.com/Luzifer/nginx-sso.git synced 2024-12-24 23:01:17 +00:00
nginx-sso/vendor/google.golang.org/grpc/Documentation/concurrency.md
Knut Ahlers 9b3c895c04
Update dependencies
Signed-off-by: Knut Ahlers <knut@ahlers.me>
2019-04-22 06:44:07 +02:00

1.5 KiB

Concurrency

In general, gRPC-go provides a concurrency-friendly API. What follows are some guidelines.

Clients

A ClientConn can safely be accessed concurrently. Using helloworld as an example, one could share the ClientConn across multiple goroutines to create multiple GreeterClient types. In this case, RPCs would be sent in parallel.

Streams

When using streams, one must take care to avoid calling either SendMsg or RecvMsg multiple times against the same Stream from different goroutines. In other words, it's safe to have a goroutine calling SendMsg and another goroutine calling RecvMsg on the same stream at the same time. But it is not safe to call SendMsg on the same stream in different goroutines, or to call RecvMsg on the same stream in different goroutines.

Servers

Each RPC handler attached to a registered server will be invoked in its own goroutine. For example, SayHello will be invoked in its own goroutine. The same is true for service handlers for streaming RPCs, as seen in the route guide example here.