$grpc.connect host=string @ $(one_of $string $glob $re) [--plaintext] [timeout=duration] [port=integer]
Create a connection to a gRPC service.
gRPC (https://grpc.io) is Google's open-source, high-performance RPC
framework, built on HTTP/2 and Protocol Buffers.
To send RPC calls to a server, you must first create a grpc connection, writing something like $conn := $($grpc.connect host=localhost service=* --plaintext).
The resulting connection struct will have one method for each endpoint on the chosen services of the host you connected to. When calling a method, there are two different ways to pass in input parameters.
If you want to pass exactly one message to the endpoint, e.g. because the endpoint does not use client streaming, you have the option of passing the fields of the message as arguments to the method call, e.g. $conn.ReverseString input=hello.
The grpc methods support tab completion of argument names. They also come with help messages (e.g. help $conn.ReverseString) that describes the input and output format.
If you want to pass multiple messages to the endpoint, you must do so by piping in a table_input_stream, where the column names of the stream are identical to the field names of the message, e.g. $list.of foo bar baz | select input={$value} | $conn.ReverseString.
Output from a gRPC method call is always a $table_input_stream, with one row per message. If an endpoint does not use server side streaming, the output always has one row.
Once you are done with a gRPC connection, you should close it to free up resources. Do so by calling the close method, e.g. $conn.close.
Input signature
This command accepts the following arguments:
host (string) the host to connect to.
service (one_of $string $glob $re) the service to connect to on this host. This can be a string, a glob or a regular expression, in order to allow you to easily specify multiple services, e.g. use * to connect to all available services.
plaintext (default: false) use plaintext instead of TLS to connect.
timeout (default: 5s) the timeout for making calls.
port (default: 50051) the port to connect to.
Examples
$conn := $($grpc.connect host=localhost service=* --plaintext)
$conn.ReverseString input="hello"
$list.of foo bar baz | select input={$value} | $conn.ReverseString
$conn.close