January 2020
Intermediate to advanced
640 pages
16h 56m
English
The constructor for each of the RPC clients that the protoc compiler generated for you expects a grpc.Connection argument. This is intentional as a single remote server might expose multiple RPC services. Given that HTTP/2 supports request multiplexing, it makes sense to instantiate a single connection to the server and share it between the various RPC clients.
So, how can we obtain a grpc.Connection instance? The grpc package provides a convenience helper called Dial, which handles all the low-level details for establishing a connection to a gRPC server. The Dial function expects the address of the gRPC server we want to connect to and a variadic list of grpc.DialOption values.
At this point, it is important ...