This is a quick spinup of a gRPC client and server in Go. It includes examples of different types of RPCs including Unary, Server Streaming, Client Streaming, and Bidirectional Streaming. This project setups a quick Postgres database with a GORM connection, and the client makes requests to the server for user actions.
Project structure follows the commuity-recommended guidlines. I also used Makefiles for cleaner code and to reduce the need to run protoc
for every protocol buffer change.
- Unary RPCs where the client sends a single request to the server and gets a single response back.
- Server streaming RPCs where the client sends a request to the server and gets a stream to read a sequence of messages back.
- Client streaming RPCs where the client writes a sequence of messages and sends them to the server, again using a provided stream.
- Bidirectional streaming RPCs where both sides send a sequence of messages using a read-write stream.
- Clone the repository to your local machine.
- Navigate to the project directory.
- To run the server, navigate to the
server
directory and runmake run
. - To run the client, navigate to the
client
directory and runmake run
in a separate terminal session.
If changes are made to the message and service definitions, re-compile protocol buffers via make generate
This project uses the following dependencies:
Look to dockerize this application -> implement this logic in microservices when deploying plant-trait model