A microservice is just a piece of code that runs as a unique process and communicates through a well-defined, lightweight mechanism to serve a business goal, which we will be writing in this recipe using https://github.com/micro/micro though there are a number of libraries available such as https://github.com/go-kit/kit and https://github.com/grpc/grpc-go, which serve the same purpose.
Creating your first microservice
Getting ready...
- Start consul agent by executing the following command:
$ consul agent -dev
- Install and run micro by executing the following commands:
$ go get github.com/micro/micro
$ micro api
2018/02/06 00:03:36 Registering RPC Handler at /rpc
2018/02/06 00:03:36 Registering API Default Handler at /
2018...