Wrapping a microservice boilerplate in golang

First things first. Happy New Years 🎉🎉🎉 Wishing you a fatal error free year!

Complexity of applications are expanding in many aspects such as scalability, development, testing and deployment. The old monolithic architecture seems entering its retirement era in enterprise-level application development. In addition, I see a desire to build systems by simply plugging together components in most software companies I’ve worked in/with. That’s why many companies developed their products based on microservice architecture. Netflix, PayPal, Amazon, eBay, and Twitter are just a few enterprises currently using microservices.

golang microservice

In this post I won’t describe microservice architecture fundamentals. If you’re unsure what a microservice is, I suggest reading Martin Fowler’s article. After reading several articles and testing some tools we ended up using golang for developing most of our microservices. Where that decision came from, benchmarking and comparing golang with others need a separate post and I won’t touch that either!

By a quick googling you’ll find some frameworks and boilerplates developed in golang but they are generally too complicated. So we built our own! I’m going to introduce the packages we used for wrapping up our microservices.


A brief introduction to GNU Screen

Recently, I was looking for a solution to keep the processes running after terminal has been closed … and ended up finding 2 main ways for doing that:

  1. Using nohup command: Which I think is the best and simplest way. You can simply use that with your long running command: nohup your-command &
  2. Using window managers and terminal multiplexers like screen and tmux: Although they can do the job but that’s not what they’re built for!

Actually “GNU Screen” or simply “screen” is a tool that brings you the ability to run multi sessions, detach from a session, resume sessions, splitting window horizontally and vertically, locking a session screen, sharing an SSH screen, etc. tmux is an alternative for screen and it seems to have more popularity among sysadmins! But in this article we stick with the screen for it’s simplicity and availability. You’re able to check tmux man page or github page for more information. Continue…