A simple idea for microservice implementation using Golang and gRPC(+protobuf)
Explore the docs »
Report Bug
·
Request Feature
Table of Contents
This project was created with the sole purpose of learning. I come from typical object-oriented synchronous language, so moving away from that into the Golang world, came with a lot of challenges. This project was a mere excuse for me to understand topics surrounding golang (such as Types, Concurrency, etc) while trying to understand how does Golang suggest to implement things that i'm used to work with in an object-oriented language (such as polymorphism, just to name one).
There are A LOT of these examples, and this is just a humble attempt of my own, by no means this should be used in production, nor should be understood as the best way to achieve a ms arch...
The implementation is quite simple, this is a routes microservices, which will be responsible for CRUD'ing routes that a given driver will attempt to access. Each route will belong to a driver, a customer and a given order. And the solution (aka which route should the driver take to deliver the order) will be served by Routific's API
Further definition of this microservice API can be found in protobuf's folder
You can either choose to build the go package or just simply run it by using the go run command. Choice is yours. Keep in mind that under /internal/client you have an example gRPC client built in Golang just for testing the service. The client is doesn't have any unit tests and it'll remain that way. This client is just for validating this PoC but shouldn't even exists on a typical service repository like this one.
Follow installation for Golang, gRPC and protobuf
You need to first create all the code for gRPC. If you're unfamiliar with how protoc
works you should start here.
Otherwise there's a bash script for you already in this same repository:
./internal/scripts/protobgenerate.sh
After code has been generated, start the server directly:
go run main.go
Or either build it and run it
go build
./microservices
After server is running, you can play with your own client, or just use the one shipped here. The client will accept os.Args, in which you can tell the client what actions should it be taking
cd internal/client
go run main.go {command-name}
Existing command names are:
- create
- read
- byDriver
Keep in mind that the arguments are hard-coded in the client itself
Distributed under the GPL-3.0 License. See LICENSE
for more information.
Emiliano Zublena - @emilianozublena - [email protected]
Project Link: https://github.com/emilianozublena/microservices