Off-the-Shelf Injection

For our final chapter in this section, we are looking at dependency injection (DI) using a framework. Choosing a DI framework that matches your preferred style can make your life significantly easier. Even if you prefer not to use a framework, examining how it is implemented and the approach it takes can be informative and help you find improvements for your preferred implementation.

While there are many frameworks available to us, including Facebook's Inject (https://github.com/facebookgo/inject) and Uber's Dig (https://godoc.org/go.uber.org/dig), for our sample service we are going to use Google's Go Cloud Wire (https://github.com/google/go-cloud/tree/master/wire).

The following topics will be covered in this chapter:

  • Off-the-shelf injection with Wire
  • Advantages of off-the-shelf injection
  • Applying off-the-shelf injection
  • Disadvantages of off-the-shelf injection
..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
18.216.42.251