-
Notifications
You must be signed in to change notification settings - Fork 112
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
chore(dot): transform telemetry
into an injectable interface
#2113
chore(dot): transform telemetry
into an injectable interface
#2113
Conversation
Co-authored-by: Quentin McGaw <quentin.mcgaw@gmail.com>
…ssamer into eclesio/net-race-conditions
dot/peerset/peerset.go
Outdated
@@ -666,15 +666,14 @@ func (ps *PeerSet) disconnect(setIdx int, reason DropReason, peers ...peer.ID) e | |||
} | |||
|
|||
// start handles all the action for the peerSet. | |||
func (ps *PeerSet) start(aq chan action, stopCh chan struct{}) { | |||
func (ps *PeerSet) start(ctx context.Context, aq chan action) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Rename aq
to actionQueue
please; also maybe restrict to a read only / write only channel if you can
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
the PeerSet.actionQueue
already is a <-chan action
(read only channel)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
So you could restrict the argument to be actionQueue chan<- action
too 😉
dot/telemetry/mailer.go
Outdated
} | ||
} | ||
|
||
func msgToJSON(message Message) ([]byte, error) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Add a MarshalJSON()
method to the Message
interface and implement them for all message types. You wouldn't have to do a marshal, then an unmarshal into a map[string]interface{}
, and then another marshal.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@timwu20 implemented!
dot/telemetry/telemetry.go
Outdated
@@ -31,4 +31,5 @@ type Client interface { | |||
// Message interface for Message functions | |||
type Message interface { | |||
messageType() string |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Does this need to be private still?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
no, changed to Type()
Changes
EXPECTs
telemetry.Telemetry
interfacetelemetry.Telemetry
interface as argumentdot.createStateService
indot.dot.createStateService
anddot.startStateService
. This is necessary because thestate.Start()
function needs the telemetry and the telemetry needs the state initialization of the database, so I decoupled the database initialization from the state service start function.Tests
Issues
t.Parallel
to all tests #2105t.Parallel()
and remove race conditions #2111Primary Reviewer