Subscribe to Blog via Email
How can we build a microservice using Go?
Like you build a microservice in any other programming language, but with the advantage that concurrency is baked into the language.
You’ll need a messaging system as your backend for services, that can talk to Golang. Kafka will, and so will NATS.
You will need a HTTP server front end in Golang, that receives RESTful service calls and passes messages from the HTTP on to an incoming messaging queue, or reads messages from an outgoing messaging queue to HTTP. labstack/echo is an example of that.
You will need a message handler and distributor in Golang, that grabs messages from a messaging queue, invokes one or more microservices on them, and puts the output of those microservices on another messaging queue.
You will need a series of microservices, coded in Golang and all running at the same time, that read in a message and output a different message.
I did not build the base framework of nsip/nias2, the Golang Microservice set I’m contributing to; my CTO Matt Farmer did, and his code is very legible. Unlike mine.
And of course, consult How is Go (programming language) used in microservice architecture?
Leave a Reply