Create a Simple Service¶
In this guide, we will generate and implement a simple gRPC service. In the following section, we will add the reverse proxy and the HTTP bindings.
Echo Service¶
To get started, let's create the following proto file.
| echo_service.proto | |
|---|---|
Code Generation¶
EasyP is a tool that simplifies the development and consumption of Protobuf APIs. One of its features is managing dependencies and building proto files.
If you decide to use EasyP, follow the instructions below or switch to the protoc tab for instructions using protoc.
Let's create a easyp.yaml with the following content:
| easyp.yaml | |
|---|---|
Now generate the artifacts using:
You should see the generated files inside the gen directory.
Implementing the Service¶
First, let's set up our Go module:
The following main.go file implements the Echo service and starts a gRPC server on port 40000:
Running the Service¶
Let's run it and ensure everything works correctly:
If everything looks good, let's proceed to the next part and add the HTTP bindings!