Building a gRPC client
Unlike JSON/HTTP services, gRPC services aren't easy for humans to interact with. They're really intended as machine-to-machine protocols, and so we must write a program if we wish to use them.
To help us do this, we are first going to add a new package inside our vault service called vault/client/grpc
. It will, given a gRPC client connection object that we get from Google's grpc
package, provide an object that performs the appropriate calls, encoding and decoding, for us, all hidden behind our own vault.Service
interface. So, we will be able to use the object as though it is just another implementation of our interface.
Create new folders inside vault so that you have the path of vault/client/grpc
. You can imagine adding other clients if you so wish, so this seems a good pattern to establish.
Add the following code to a new client.go
file:
func New(conn *grpc.ClientConn) vault.Service { var hashEndpoint = grpctransport.NewClient( conn, "Vault...