We will use Go Micro and our encryption logic in utils to write a microservice. A Go microservice should be built in a step-wise manner. To create a service, we need to design a few entities upfront. They are as follows:
- A protocol buffer file for defining RPC methods of service
- A handler file that has an actual implementation of methods
- A server that exposes RPC methods
- A client that can make RPC requests and get results
We need two system level-tools called protoc and protoc-gen-micro for compiling protocol buffers to Go packages. Let's see the steps for creating an encryption microservice, as follows:
- Let's install those compilers using the go get command, as follows:
> go get -u github.com/golang/protobuf/protoc-gen-go ...