Hey :)
So a few places depend on Go's built-in http.client directly, or indirectly (through httpclient.go).
My thought was that it could be an improvement to work towards injecting http.client as a dependency - this would decouple several functions away from it, improving their testability.
As an initial first step, I could make a change that:
- Refactors
httpclient.SendRequest to accept a *http.client parameter.
- In usages of
httpclient.SendRequest, have them construct a *http.client to inject using httpClient.GetHttpClient
- Create some unit tests for
httpclient.SendRequest.
Of course, usages http.SendRequest would still depend indirectly on http.client ( via httpClient.GetHttpClient), but this would get us a foot in the door regarding doing more dependency injection elsewhere.
I've seen some other issues that discuss how heavily coupled some functions are, and I believe dependency injection could help us improve some of those tight coupling problems
This would be my first open source contribution in a while, and my first Go work in a few years, so your thoughts are especially welcome here :)
My team have also been making heavy use of this tool for a while and it's been really helpful, so thank you! ❤️
Hey :)
So a few places depend on Go's built-in
http.clientdirectly, or indirectly (throughhttpclient.go).My thought was that it could be an improvement to work towards injecting
http.clientas a dependency - this would decouple several functions away from it, improving their testability.As an initial first step, I could make a change that:
httpclient.SendRequestto accept a*http.clientparameter.httpclient.SendRequest, have them construct a*http.clientto inject usinghttpClient.GetHttpClienthttpclient.SendRequest.Of course, usages
http.SendRequestwould still depend indirectly onhttp.client( viahttpClient.GetHttpClient), but this would get us a foot in the door regarding doing more dependency injection elsewhere.I've seen some other issues that discuss how heavily coupled some functions are, and I believe dependency injection could help us improve some of those tight coupling problems
This would be my first open source contribution in a while, and my first Go work in a few years, so your thoughts are especially welcome here :)
My team have also been making heavy use of this tool for a while and it's been really helpful, so thank you! ❤️