-
Notifications
You must be signed in to change notification settings - Fork 435
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
Refactor websocket handler to protect against concurrent writes #811
Conversation
[APPROVALNOTIFIER] This PR is NOT APPROVED This pull-request has been approved by: The full list of commands accepted by this bot can be found here.
Needs approval from an approver in each of these files:
Approvers can indicate their approval by writing |
|
||
func (w *webSocketResponseWriter) writeMessage(b []byte) error { | ||
w.client.send <- b | ||
return nil // TODO(pcj): is there a need to propagate write errors? |
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.
I think at best we'll end up logging them, so we probably can just log it in the websocket writer.
// Flush implements the https://golang.org/pkg/net/http/#Flusher interface. | ||
func (w *webSocketResponseWriter) Flush() { | ||
// no-op | ||
} |
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 always a no-op, or can we coerce the websocket writer to implement this?
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.
Nice work, really liking where this is going. I'm wondering, if we're using significant amounts of the code from the gorilla library, should we include a copy of their license in this directory too? Their license isn't in conflict with ours, I hope?
FYI #815 was just opened as an alternative fix for the underlying issue. |
#815 looks like a simpler change. I'll test that one out in my environment and if it seems OK, will plan to close this PR. I did make some significant inroads on a test suite for the websocket functionality; I can contribute that as a separate PR. |
Thanks a lot, Paul 🙏🏻, that sounds good. |
wrapper.go
towebsocket_handler.go
.websocket_client.go
andwebsocket_clienthub.go
to manage concurrent requests.webSocketResponseWriter
to send messages to the client hub rather than write to the websocket directly.Still working on this. Needs a proper test.
Closes #713