In the new pattern, the caller of trySendWith only needs to tie together two related things (metric.Line and pointSender), whereas before they needed to chose correctly 3 times (metric.Line, pointHandler, PointsTracker).
The new pattern also mostly allows us to avoid line, err as local variables, so that the Send* methods can be as short as 1 line.
Other opportunistic changes
rename 'LineHandler' interface to 'BatchBuilder' - the main responsibility of this type seems to be collecting lines for a particular point type into batches of the right size and periodically flushing them. Maybe it should actually be called 'BatchBuffer'?
moves some line-building logic from SendDelta into a new delta.Line func
renames reporter to batchingHTTPReporter (or maybe it should be HTTPBatchReporter)
Issues
[ ] need to backfill tests for delta.Line
[ ] wavefront_sender_test.go has gotten a little weird - it mocks a 2nd-degree dependency instead of a direct one.
[ ] finalize or revert renames of LineHandler and reporter
This PR consolidates a repetitive
trySendWith
pattern insenders.realSender
into a simpler pattern.This PR assumes that #175 will be merged first
Old Pattern
New Pattern
In the new pattern, the caller of
trySendWith
only needs to tie together two related things (metric.Line
andpointSender
), whereas before they needed to chose correctly 3 times (metric.Line
,pointHandler
,PointsTracker
).The new pattern also mostly allows us to avoid
line, err
as local variables, so that theSend*
methods can be as short as 1 line.Other opportunistic changes
SendDelta
into a newdelta.Line
funcreporter
tobatchingHTTPReporter
(or maybe it should beHTTPBatchReporter
)Issues
delta.Line
wavefront_sender_test.go
has gotten a little weird - it mocks a 2nd-degree dependency instead of a direct one.LineHandler
andreporter
TypedSender
is not a great name