Make senders.Sender be a concrete type.#115
Make senders.Sender be a concrete type.#115keep94 wants to merge 3 commits intowavefrontHQ:masterfrom
Conversation
senders/client.go
Outdated
|
|
||
| // Sender Interface for sending metrics, distributions and spans to Wavefront | ||
| type Sender interface { | ||
| type senderSpec interface { |
There was a problem hiding this comment.
Could we give this a different name that describes its function more? I'm not sure what it would be, since its responsibility seems to be "sending". I was thinking about about the http.Client object and its internal Transport.
|
I can't quite get all my guiding principles to line up toward a single conclusion about this API 😅 On the one hand, there's "depend on interfaces, not implementations", which suggests that The "private implementation of public interface" pattern seems common in go packages and it hasn't bothered me up to this point. If anything I've kind of liked not having the concrete type exported. @keep94 your main concern is that if I wonder if we'll ever have a reason in the future for two different implementations of I wonder if we'd miss any flexibility for testing that the interface-based approach offers - right now consumers of the library could make a fake sender and use that in their unit tests if they wanted to, which is nice, but then again they can make their own private interface for that.
Yeah, if we're not exporting I wonder if we should change the type names while we're at it? is |
With Sender a concrete class, these interfaces are no longer used.
|
@keep94 I just thought of something - I think that eliminating the interface means that |
|
@LukeWinikates actually in this PR where I get rid of the interface MultiSender does work. The reason why is because the Sender concrete type has an interface inside. Like I said before, we can go with PR #116, if you want to keep the interface, just know that we won't be able to do examples on individual methods of the Sender interface. @oppegard is back from training, and he will have feedback too. |
|
We decided to leave Sender as an interface so we merged #116 instead. |
Here is what I am thinking about making senders.Sender be a concrete type. This is a breaking change that will cause most clients to have to change their code. Mostly the change will be replace
senders.Senderwith*senders.SenderAfter doing this exercise, I am thinking we probably don't need the DistributionSender, MetricSender, or EventSender interfaces. They are declared in the sender package but they don't seem to be used anywhere. We can get rid of these extra interfaces in another PR.