-
Notifications
You must be signed in to change notification settings - Fork 471
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
network: add OutgoingMessage disconnectReason field #5147
network: add OutgoingMessage disconnectReason field #5147
Conversation
Codecov Report
@@ Coverage Diff @@
## master #5147 +/- ##
==========================================
- Coverage 53.56% 53.54% -0.03%
==========================================
Files 433 433
Lines 54736 54736
==========================================
- Hits 29321 29310 -11
- Misses 23136 23141 +5
- Partials 2279 2285 +6
📣 We’re building smart automated test selection to slash your CI/CD build times. Learn more |
ebd951b
to
a2503f6
Compare
return OutgoingMessage{Broadcast, msg.Tag, msg.Data, nil} | ||
return OutgoingMessage{Action: Broadcast, Tag: msg.Tag, Payload: msg.Data, Topics: nil} |
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.
was this a required change? just wondering because I don't see a difference besides adding the attribute names.
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.
yes, adding an extra field made struct initializations not work here because all the fields have to be specified if you aren't providing the field names.
reason := disconnectBadData | ||
if outmsg.reason != disconnectReasonNone { | ||
reason = outmsg.reason | ||
} | ||
go wn.disconnectThread(msg.Sender, reason) |
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.
clever! I was thinking about the work required to include the badData to all disconnect messages, but this is way cleaner.
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.
yes, it is the current default and is already being set in this line, so I kept it set as default here in the line I replaced it with
Summary
Following up on feedback from #4695, this adds an unexported disconnectReason field to the OutgoingMessage field for use with tracking internal network handlers' reasons for disconnecting.
Test Plan
Extended TestWebsocketDisconnection to use this new feature and assert the correct reason was reported.