Evans - a CLI gRPC Client
gRPC Server testing, but how?
If you develop a REST or GraphQL Api you have various tools available that support you in testing. I personally use Insomnia here, many will also use Postman. But some people will simply use cURL. Such tools appear to be less common for gRPC.
A tool that I find very useful and that helps me when I work with a gRPC service is Evans.
Installation & Setup
Installation is easiest on MacOS:
Binaries for Linux and Windows are also available on Github.
In order to be able to use Evans effectively, I definitely recommend switching on gRPC Reflection. In Go this could look like this:
Evans starts in repl mode with
If Reflection enabled as described above, you can display the available services with show package and switch to a service with packache ServiceName.
The whole point, of course, is to test RPCs. Here, too, reflection helps us. If you have chosen a package you can use show Service to display which services are available in the package.
The nice thing is that you can also see the RPCs including request and response types.
To be able to work with the service, it must be selected. service ServiceName selects a service and now you can display the available RPCs with show rpc:
With call RPCname you can now call RPCs. In my example here, I am calling Save. Evans now asks interactively the individual fields that are necessary for the call. As you can see, further information is also displayed here. repeate indicates that addresslist is an array and what type the individual fields are. The protobuf file looks like this:
Conclusion and alternatives
Of course, this can only serve as an overview. Evans can do a lot more, including streaming testing.
Personally, I think it makes testing a lot easier. I think it’s a good thing that it’s a CLI tool, because you don’t always have a GUI available.
There are of course alternatives. e.g. Bloom RPC is an electron client for gRPC with a nice GUI. Who e.g. is familiar with GraphiQL you will quickly find your way around here.
gRPC Curl is certainly an option for some.