Building micro-services using go-swagger

By Myles McDonnell

Elevator Pitch

Learn how to define micro-service contracts with Swagger (http://swagger.io) and use go-swagger (http://bit.ly/go-swag) to generate a Go server skeleton and client package. This talk focuses on developer productivity from inception to production and is based on real world experience.

Description

This talk will follow a step by step demonstration of how to build a micro-service written in Go using the Swagger specification and the open source toolset go-swagger. This talk is based on real word experience in building micro-services that went into production earlier this year on a Kubernetes cluster in support of a new shipping fleet management system. The talk is very practical in nature and as such will focus on developer productivity.

The techniques used to create an effective and efficient development process will be discussed and demonstrated, from inception of the project and the first line of code right through to integration testing and the production of the deployment artefact; an Alpine Linux based Docker image containing the compiled binary.

Key sections:

  • Brief introduction to Swagger
  • Writing the specification
  • Splitting the specification into multiple files and why this is a good idea; readability and change traceability in VCS system
  • Reconstitution of the specification into a single file
  • Building the server skeleton and client package
  • Writing code to implement service functionality
  • Re-building the server skeleton post API changes
  • Writing integration tests
  • Configuration of the Continuous Integration build (using ConcourseCI to build, test and publish an Alpine Linux Docker image.
  • Live demo deploying and running on Kubernetes.

Please see the Github repository, docker image and Prezi.

Notes

The talk is aimed at all levels of conference attendee. Some live Go coding will take place and the behaviour/structure of the code will be explained as it is written.

The speaker did not write go-swagger which was written predominantly by Ivan Porto Carrero who is aware of and has approved the submission of this talk. However, the talk is not about the production of go-swagger, rather the practical application of it along with the various other considerations required to deliver a robust system into production.