These are the slides from the talk I gave at Golab Conf 2020 - https://golab.io/
The links from the slides:
1. Personal Site - https://pmihaylov.com/
2. Github Profile - https://github.com/preslavmihaylov
3. Fx Framework - https://github.com/uber-go/fx
4. Fx Framework Tutorial (Part 1) - https://pmihaylov.com/dependency-injection-go-fx/
5. Fx Framework Tutorial (Part 2) - https://pmihaylov.com/shared-components-go-microservices/
6. Introduction to Guice from Google (Java) - https://www.youtube.com/watch?v=hBVJbzAagfs&ab_channel=GoogleDevelopers
Talk Abstract follows...
In this talk, I will show you how to handle complex dependency graphs in Go using the Fx framework. It can make your life easier in many regards, but its greatest value is in the way it enables you to modularize & share your infrastructure code across multiple microservices.
The talk focuses on introducing the concept of dependency injection & its implementation in Go using the Fx framework (https://github.com/uber-go/fx). Apart from providing a dependency injection mechanism, this framework enables you to separate your application into distinct, independent modules, which can be shared across multiple codebases. This is especially valuable in a microservice environment, where every service has a lot of "boilerplate" infrastructure code which has to be present on any service regardless of its business logic.
In a typical microservice architecture, every service needs some kind of a healthcheck, an ELK/monitoring client, tracing clients & various other integrations specific to your server environment. By extracting this common piece of software in a module, which can be "plugged in" and reused across services using Fx, one can greatly reduce development time & maintenance cost as you'd need to deal with "wiring infra" only once & reuse that across your codebase.