SlideShare a Scribd company logo
Microservices in Go with Go kit
Shiju Varghese
https://medium.com/@shijuvar
DevConf.IN
August 02, 2019
Bengaluru
About Me
• Consulting Solutions Architect on Go and Distributed Systems

• Published Author: Web Development with Go and Go Recipes
• Awarded Microsoft MVP seven times

• Speaker at numerous conferences

• medium.com/@shijuvar | github.com/shijuvar | linkedin.com/in/shijuvar
Agenda
• Introduction to Microservices Architecture 

• Introduction to Go kit

• Building Microservices with Go kit
Microservices Architecture
Scale Cube : 3 Dimensions to Scale
Microservices is an architectural style for building
highly scalable applications, in which an application
decomposes into a set of services as functional
components.
Microservices Architecture is all about functional
decomposition.
• A modern, practical programming language
• Concurrent, Simple, Fast, Type-safe, Compiled very quickly
• A great language for Cloud-Native, Microservices
Go Programming Language
Go kit
Go kit
• A programming toolkit (collection of Go packages) for building
robust, reliable, maintainable microservices
• Solves common problems in distributed systems
• Bootstrap development towards Microservices
• Go kit design is well-suited for modern software design: both
microservices and elegant monoliths
Go kit Architecture
There are three major components in the Go kit based application
architecture:

• Transport layer: The transport domain 

• Endpoint layer: An RPC method

• Service layer: Business logic layer
Transports
• The transport domain is bound to concrete transports 

• Provide transports like HTTP, gRPC, NATS, AMQP, Thrift, etc

• A single microservice can support multiple transports
Endpoints
• An RPC method bound to a service method

• RPC as the primary messaging pattern

• Each endpoint exposes the service method to the outside world using
Transport layer 

type Endpoint func(ctx context.Context, request interface{}) (response
interface{}, err error)
Services
• Business logic modelled as interfaces

• Based on the Clean Architecture or the Hexagonal Architecture

• No knowledge about endpoint, concrete transports and encoding/
decoding
Clean Architecture
The central rule of The Clean Architecture is
the Dependency Rule, which says:
Source code dependencies can only point inwards.
In other words, the source code of each circle can
only access code in an inner circle but never any
code in an outer circle.
Flow of requests and responses
• Request flow: Transport layer -> Endpoint layer -> Service layer

• Response flow: Service layer -> Endpoint layer -> Transport layer
Demo: Building Services with Go kit
Middleware
• A strict separation of concerns through use of the decorator

• Wrap endpoints or services to add functionality, such as logging, rate
limiting and distributed tracing

• Two types of middlewares: Endpoint middleware and Service middleware
Endpoint Middleware
• An endpoint middleware is a function that takes an endpoint and returns
an endpoint.

type Middleware func(Endpoint) Endpoint
• Use endpoint middlewares for transport-domain concerns, like circuit
breaking and rate limiting.
Microservices in Go with Go kit
Service Middleware
• An service middleware is a function that takes a service and returns a
service.

type Middleware func(Service) Service
• Use service middlewares for business-domain concerns, like logging and
instrumentation.
Microservices in Go with Go kit
Demo: Wrapping Go kit services
with Middlewares
Design of Go kit services
1. Implements the core business logic by defining
an interface for service and providing a concrete
implementation.

2. Writes service middlewares to provide additional
functionality, like logging, analytics,
instrumentation — anything that needs
knowledge of business domain.

3. Go kit provides endpoint and transport domain
middlewares, for functionality like rate limiting,
circuit breaking, load balancing, and distributed
tracing — all of which are generally agnostic to
business domain.
Source Code
https://github.com/shijuvar/gokit-examples
Thanks
Shiju Varghese
gophermonk@gmail.com
https://medium.com/@shijuvar
https://github.com/shijuvar
https://linkedin.com/in/shijuvar
Go Programming Workshops: https://bit.ly/shijuv-go

More Related Content

What's hot (20)

PDF
Playwright: A New Test Automation Framework for the Modern Web
Applitools
 
PPTX
Angular
Mouad EL Fakir
 
PPTX
Flutter
Himanshu Singh
 
PPTX
API Testing with Frisby and Mocha
Lyudmila Anisimova
 
PPT
documentation-testing.ppt
Roopa slideshare
 
PDF
TypeScript - An Introduction
NexThoughts Technologies
 
PDF
Understanding Monorepos
Benjamin Cabanes
 
PDF
Inter-Process Communication in Microservices using gRPC
Shiju Varghese
 
PDF
Angular Advanced Routing
Laurent Duveau
 
PDF
gRPC and Microservices
Jonathan Gomez
 
PDF
The story of SonarQube told to a DevOps Engineer
Manu Pk
 
PDF
The Go programming language - Intro by MyLittleAdventure
mylittleadventure
 
PPTX
SonarQube Presentation.pptx
Satwik Bhupathi Raju
 
PDF
Introduction to API
rajnishjha29
 
PPTX
Browser Automation with Playwright – for integration, RPA, UI testing and mor...
Lucas Jellema
 
PPT
Introduction to c#
OpenSource Technologies Pvt. Ltd.
 
PDF
Introduction to Kotlin coroutines
Roman Elizarov
 
PPTX
Golang - Overview of Go (golang) Language
Aniruddha Chakrabarti
 
Playwright: A New Test Automation Framework for the Modern Web
Applitools
 
API Testing with Frisby and Mocha
Lyudmila Anisimova
 
documentation-testing.ppt
Roopa slideshare
 
TypeScript - An Introduction
NexThoughts Technologies
 
Understanding Monorepos
Benjamin Cabanes
 
Inter-Process Communication in Microservices using gRPC
Shiju Varghese
 
Angular Advanced Routing
Laurent Duveau
 
gRPC and Microservices
Jonathan Gomez
 
The story of SonarQube told to a DevOps Engineer
Manu Pk
 
The Go programming language - Intro by MyLittleAdventure
mylittleadventure
 
SonarQube Presentation.pptx
Satwik Bhupathi Raju
 
Introduction to API
rajnishjha29
 
Browser Automation with Playwright – for integration, RPA, UI testing and mor...
Lucas Jellema
 
Introduction to Kotlin coroutines
Roman Elizarov
 
Golang - Overview of Go (golang) Language
Aniruddha Chakrabarti
 

Similar to Microservices in Go with Go kit (20)

PPTX
Application Centric Microservices from Redhat Summit 2015
Ken Owens
 
PDF
Istio as an enabler for migrating to microservices (edition 2022)
Ahmed Misbah
 
PDF
Service Mesh Talk for CTO Forum
Rick Hightower
 
PDF
Ekon20 mORMot SOA Delphi Conference
Arnaud Bouchez
 
PDF
Migrating to Microservices Patterns and Technologies (edition 2023)
Ahmed Misbah
 
PDF
Microdeployments for microservices dev ops nashville
Nathaniel (Ned) Bauerle
 
PDF
Automating Applications with Habitat - Sydney Cloud Native Meetup
Matt Ray
 
PPTX
Business and IT agility through DevOps and microservice architecture powered ...
Lucas Jellema
 
PDF
Practical Microservice Architecture (edition 2022).pdf
Ahmed Misbah
 
PPTX
Designing Microservices
David Chou
 
PPTX
Microservices-101
Subhashish Bhattacharjee
 
PPTX
Micro service session 1
Amin Arab
 
PPTX
MICROSERVICES ARCHITECTURE unit -2.pptx
MohammedShahid562503
 
PDF
Newt global meetup microservices
Venkatnadhan Thirunalai
 
PPTX
Continuous Integration
XPDays
 
PPTX
Shopify - CNCF March 2025 Meetup - Presentation - 26-03-25.pptx
Michael Foster
 
PDF
CV - Abhijit
Abhijit Kumar
 
PPTX
Rez gateway (RezOS) innovate the future
indikaMaligaspe
 
PPTX
Rez gateway - RezOS - innovate the future
indikaMaligaspe
 
PPTX
Agile methodology in cloud computing
Ahmed M. Abed
 
Application Centric Microservices from Redhat Summit 2015
Ken Owens
 
Istio as an enabler for migrating to microservices (edition 2022)
Ahmed Misbah
 
Service Mesh Talk for CTO Forum
Rick Hightower
 
Ekon20 mORMot SOA Delphi Conference
Arnaud Bouchez
 
Migrating to Microservices Patterns and Technologies (edition 2023)
Ahmed Misbah
 
Microdeployments for microservices dev ops nashville
Nathaniel (Ned) Bauerle
 
Automating Applications with Habitat - Sydney Cloud Native Meetup
Matt Ray
 
Business and IT agility through DevOps and microservice architecture powered ...
Lucas Jellema
 
Practical Microservice Architecture (edition 2022).pdf
Ahmed Misbah
 
Designing Microservices
David Chou
 
Microservices-101
Subhashish Bhattacharjee
 
Micro service session 1
Amin Arab
 
MICROSERVICES ARCHITECTURE unit -2.pptx
MohammedShahid562503
 
Newt global meetup microservices
Venkatnadhan Thirunalai
 
Continuous Integration
XPDays
 
Shopify - CNCF March 2025 Meetup - Presentation - 26-03-25.pptx
Michael Foster
 
CV - Abhijit
Abhijit Kumar
 
Rez gateway (RezOS) innovate the future
indikaMaligaspe
 
Rez gateway - RezOS - innovate the future
indikaMaligaspe
 
Agile methodology in cloud computing
Ahmed M. Abed
 
Ad

More from Shiju Varghese (20)

PDF
Building Modern Distributed Applications in Go with Service Weaver
Shiju Varghese
 
PDF
NATS: A Cloud Native Messaging System
Shiju Varghese
 
PDF
Event-Driven Microservices With NATS Streaming
Shiju Varghese
 
PDF
Building Microservices with gRPC and NATS
Shiju Varghese
 
PDF
Building Scalable Backends with Go
Shiju Varghese
 
PDF
A Primer to Containerization & Microservices
Shiju Varghese
 
PDF
Building RESTful Services With Go and MongoDB
Shiju Varghese
 
PDF
Docker and Kubernetes
Shiju Varghese
 
PDF
Practicing Mindfulness
Shiju Varghese
 
PPSX
Azure DocumentDB
Shiju Varghese
 
PPSX
Azure Mobile Services .NET Backend
Shiju Varghese
 
PDF
Windows Azure Mobile Services
Shiju Varghese
 
PDF
JavaScript, Meet Cloud : Node.js on Windows Azure
Shiju Varghese
 
PPSX
Introduction to Node js
Shiju Varghese
 
PPSX
Windows Azure Cloud Services
Shiju Varghese
 
PPSX
Windows Azure Webs Sites
Shiju Varghese
 
PPS
Building Apps with Node.js
Shiju Varghese
 
PPSX
Node on Windows Azure
Shiju Varghese
 
PPTX
Introducing Razor - A new view engine for ASP.NET
Shiju Varghese
 
PPTX
NoSQL Database in .NET Apps
Shiju Varghese
 
Building Modern Distributed Applications in Go with Service Weaver
Shiju Varghese
 
NATS: A Cloud Native Messaging System
Shiju Varghese
 
Event-Driven Microservices With NATS Streaming
Shiju Varghese
 
Building Microservices with gRPC and NATS
Shiju Varghese
 
Building Scalable Backends with Go
Shiju Varghese
 
A Primer to Containerization & Microservices
Shiju Varghese
 
Building RESTful Services With Go and MongoDB
Shiju Varghese
 
Docker and Kubernetes
Shiju Varghese
 
Practicing Mindfulness
Shiju Varghese
 
Azure DocumentDB
Shiju Varghese
 
Azure Mobile Services .NET Backend
Shiju Varghese
 
Windows Azure Mobile Services
Shiju Varghese
 
JavaScript, Meet Cloud : Node.js on Windows Azure
Shiju Varghese
 
Introduction to Node js
Shiju Varghese
 
Windows Azure Cloud Services
Shiju Varghese
 
Windows Azure Webs Sites
Shiju Varghese
 
Building Apps with Node.js
Shiju Varghese
 
Node on Windows Azure
Shiju Varghese
 
Introducing Razor - A new view engine for ASP.NET
Shiju Varghese
 
NoSQL Database in .NET Apps
Shiju Varghese
 
Ad

Recently uploaded (20)

PDF
HCIP-Data Center Facility Deployment V2.0 Training Material (Without Remarks ...
mcastillo49
 
PDF
CIFDAQ Market Insights for July 7th 2025
CIFDAQ
 
PDF
From Code to Challenge: Crafting Skill-Based Games That Engage and Reward
aiyshauae
 
PPTX
Webinar: Introduction to LF Energy EVerest
DanBrown980551
 
PPTX
"Autonomy of LLM Agents: Current State and Future Prospects", Oles` Petriv
Fwdays
 
PDF
Complete JavaScript Notes: From Basics to Advanced Concepts.pdf
haydendavispro
 
PDF
CIFDAQ Weekly Market Wrap for 11th July 2025
CIFDAQ
 
PDF
Chris Elwell Woburn, MA - Passionate About IT Innovation
Chris Elwell Woburn, MA
 
PDF
Timothy Rottach - Ramp up on AI Use Cases, from Vector Search to AI Agents wi...
AWS Chicago
 
PDF
Reverse Engineering of Security Products: Developing an Advanced Microsoft De...
nwbxhhcyjv
 
PDF
"AI Transformation: Directions and Challenges", Pavlo Shaternik
Fwdays
 
PDF
Bitcoin for Millennials podcast with Bram, Power Laws of Bitcoin
Stephen Perrenod
 
PDF
Jak MŚP w Europie Środkowo-Wschodniej odnajdują się w świecie AI
dominikamizerska1
 
PDF
July Patch Tuesday
Ivanti
 
PPTX
COMPARISON OF RASTER ANALYSIS TOOLS OF QGIS AND ARCGIS
Sharanya Sarkar
 
PDF
Log-Based Anomaly Detection: Enhancing System Reliability with Machine Learning
Mohammed BEKKOUCHE
 
PPTX
UiPath Academic Alliance Educator Panels: Session 2 - Business Analyst Content
DianaGray10
 
PDF
Building Real-Time Digital Twins with IBM Maximo & ArcGIS Indoors
Safe Software
 
PPTX
From Sci-Fi to Reality: Exploring AI Evolution
Svetlana Meissner
 
PPTX
Q2 FY26 Tableau User Group Leader Quarterly Call
lward7
 
HCIP-Data Center Facility Deployment V2.0 Training Material (Without Remarks ...
mcastillo49
 
CIFDAQ Market Insights for July 7th 2025
CIFDAQ
 
From Code to Challenge: Crafting Skill-Based Games That Engage and Reward
aiyshauae
 
Webinar: Introduction to LF Energy EVerest
DanBrown980551
 
"Autonomy of LLM Agents: Current State and Future Prospects", Oles` Petriv
Fwdays
 
Complete JavaScript Notes: From Basics to Advanced Concepts.pdf
haydendavispro
 
CIFDAQ Weekly Market Wrap for 11th July 2025
CIFDAQ
 
Chris Elwell Woburn, MA - Passionate About IT Innovation
Chris Elwell Woburn, MA
 
Timothy Rottach - Ramp up on AI Use Cases, from Vector Search to AI Agents wi...
AWS Chicago
 
Reverse Engineering of Security Products: Developing an Advanced Microsoft De...
nwbxhhcyjv
 
"AI Transformation: Directions and Challenges", Pavlo Shaternik
Fwdays
 
Bitcoin for Millennials podcast with Bram, Power Laws of Bitcoin
Stephen Perrenod
 
Jak MŚP w Europie Środkowo-Wschodniej odnajdują się w świecie AI
dominikamizerska1
 
July Patch Tuesday
Ivanti
 
COMPARISON OF RASTER ANALYSIS TOOLS OF QGIS AND ARCGIS
Sharanya Sarkar
 
Log-Based Anomaly Detection: Enhancing System Reliability with Machine Learning
Mohammed BEKKOUCHE
 
UiPath Academic Alliance Educator Panels: Session 2 - Business Analyst Content
DianaGray10
 
Building Real-Time Digital Twins with IBM Maximo & ArcGIS Indoors
Safe Software
 
From Sci-Fi to Reality: Exploring AI Evolution
Svetlana Meissner
 
Q2 FY26 Tableau User Group Leader Quarterly Call
lward7
 

Microservices in Go with Go kit

  • 1. Microservices in Go with Go kit Shiju Varghese https://medium.com/@shijuvar DevConf.IN August 02, 2019 Bengaluru
  • 2. About Me • Consulting Solutions Architect on Go and Distributed Systems • Published Author: Web Development with Go and Go Recipes • Awarded Microsoft MVP seven times • Speaker at numerous conferences • medium.com/@shijuvar | github.com/shijuvar | linkedin.com/in/shijuvar
  • 3. Agenda • Introduction to Microservices Architecture • Introduction to Go kit • Building Microservices with Go kit
  • 5. Scale Cube : 3 Dimensions to Scale
  • 6. Microservices is an architectural style for building highly scalable applications, in which an application decomposes into a set of services as functional components. Microservices Architecture is all about functional decomposition.
  • 7. • A modern, practical programming language • Concurrent, Simple, Fast, Type-safe, Compiled very quickly • A great language for Cloud-Native, Microservices Go Programming Language
  • 9. Go kit • A programming toolkit (collection of Go packages) for building robust, reliable, maintainable microservices • Solves common problems in distributed systems • Bootstrap development towards Microservices • Go kit design is well-suited for modern software design: both microservices and elegant monoliths
  • 10. Go kit Architecture There are three major components in the Go kit based application architecture: • Transport layer: The transport domain • Endpoint layer: An RPC method • Service layer: Business logic layer
  • 11. Transports • The transport domain is bound to concrete transports • Provide transports like HTTP, gRPC, NATS, AMQP, Thrift, etc • A single microservice can support multiple transports
  • 12. Endpoints • An RPC method bound to a service method • RPC as the primary messaging pattern • Each endpoint exposes the service method to the outside world using Transport layer type Endpoint func(ctx context.Context, request interface{}) (response interface{}, err error)
  • 13. Services • Business logic modelled as interfaces • Based on the Clean Architecture or the Hexagonal Architecture • No knowledge about endpoint, concrete transports and encoding/ decoding
  • 14. Clean Architecture The central rule of The Clean Architecture is the Dependency Rule, which says: Source code dependencies can only point inwards. In other words, the source code of each circle can only access code in an inner circle but never any code in an outer circle.
  • 15. Flow of requests and responses • Request flow: Transport layer -> Endpoint layer -> Service layer • Response flow: Service layer -> Endpoint layer -> Transport layer
  • 16. Demo: Building Services with Go kit
  • 17. Middleware • A strict separation of concerns through use of the decorator • Wrap endpoints or services to add functionality, such as logging, rate limiting and distributed tracing • Two types of middlewares: Endpoint middleware and Service middleware
  • 18. Endpoint Middleware • An endpoint middleware is a function that takes an endpoint and returns an endpoint. type Middleware func(Endpoint) Endpoint • Use endpoint middlewares for transport-domain concerns, like circuit breaking and rate limiting.
  • 20. Service Middleware • An service middleware is a function that takes a service and returns a service. type Middleware func(Service) Service • Use service middlewares for business-domain concerns, like logging and instrumentation.
  • 22. Demo: Wrapping Go kit services with Middlewares
  • 23. Design of Go kit services 1. Implements the core business logic by defining an interface for service and providing a concrete implementation. 2. Writes service middlewares to provide additional functionality, like logging, analytics, instrumentation — anything that needs knowledge of business domain. 3. Go kit provides endpoint and transport domain middlewares, for functionality like rate limiting, circuit breaking, load balancing, and distributed tracing — all of which are generally agnostic to business domain.