Evans CLI — A Go gRPC Client

Author:

July 10, 2023

4 min read

image

Evans CLI is a command-line tool designed to facilitate interaction with Go gRPC services. It offers a range of features that simplify the testing and debugging of gRPC services. Here are some of the advantages of using Evans CLI.

Advantages of Evans CLI

Evans CLI stands out from other tools for interacting with gRPC services due to the following advantages:

  • Ease of use: Evans CLI provides a simple command-line interface, making it incredibly user-friendly. It allows you to effortlessly send requests and receive responses from gRPC services.
  • Powerful features: Evans CLI boasts several powerful features that streamline the testing and debugging process. These features include automatic service discovery, an interactive mode, and code generation capabilities.
  • Open source: Evans CLI is an open-source tool, which means it is free to use and modify. This makes it a flexible and cost-effective choice for developers.

Installation of Evans CLI

To install Evans CLI, follow these steps:

Sample gRPC Server Project

For the purpose of demonstrating the usage of Evans CLI, let’s consider a sample gRPC server that implements CRUD (Create, Read, Update, Delete) operations based on an office protocol file.

You can find the source code for this sample project here.

How Evans CLI Solves Client-Side Issues for the gRPC Server

Evans CLI addresses client-side issues for the gRPC server through its REPL (Read-Eval-Print Loop) mode and CLI (Command Line Interface) mode. In this example, we will focus on the REPL mode, as it offers a more user-friendly way to interact with the server.

To start the Evans CLI client in REPL mode, execute the following command in the root directory of your project:

bash

evans -r repl -p <your-gRPC-server-port>

Untitled.png

Here are some useful commands you can utilize with Evans CLI:

  • To view the available packages on your server, use the command:

bash

show package

Untitled.png

  • To select a specific package from the available options, use the command:

bash

package <Package_Name>

For example:

bash

package gen

Untitled.png

  • To view the services within the selected package, use the command:

bash

show service

Untitled.png

  • To select a specific service from the available options, use the command:

bash

service <Service_Name>

For example:

bash

service OfficeService

Untitled.png

  • To view the messages within the services.package, use the command:

bash

show message

Untitled.png

  • To obtain more information about a particular message and its fields, use the command:

bash

desc <Message_Name>

For example:

bash

desc Office
  • To view the RPC methods available in the services, use the command:

bash

show rpc
  • To call a method from a service, use the command:

bash

call <rpc-method-name>

For example:

bash

call CreateOffice

Untitled.png

Untitled.png

Conclusion

Evans CLI is a powerful tool that simplifies the testing and debugging of Go gRPC services. With its easy-to-use interface, rich set of features, and open-source nature, Evans CLI provides developers with an efficient way to interact with gRPC servers.

By installing Evans CLI and utilizing its REPL mode, developers can seamlessly explore, inspect, and test the different APIs exposed by their gRPC servers. This interactive approach enhances the development workflow, improves efficiency, and boosts confidence in the reliability of gRPC-based systems.

Embrace Evans CLI as your go-to tool for testing and debugging Go gRPC services, and experience the benefits of its simplicity, power, and open-source nature. Happy coding!