-
-
Notifications
You must be signed in to change notification settings - Fork 33.5k
inspector: refactor to rename and comment methods #13321
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
Conversation
76825ed
to
76d70ed
Compare
src/inspector_io.cc
Outdated
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.
This is inside an anonymous namespace, adding static
doesn’t do anything here
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.
Thanks, I didn't notice that, I'll review all the statics for this (so you don't have to comment on each one).
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.
Removing statics in anonymous namespaces will reduce the size of this patch.
src/inspector_agent.h
Outdated
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 don't think there's ever be a need. And if we manage to make WS transport talk to inspector through the JS API then there will be only one InspectorSessionDelegate implementation, which will remove the need for this interface.
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 mean that I find "OnMessage()" to not clearly indicate the purpose, from the name it could be used to send messages either way, whereas SendMessageToFrontend()
clearly indicates the direction of the message flow.
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 agree. Still hope to get rid of this interface soon :)
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.
Got it. I'll rename, only takes a minute, and I promise I will feel no sadness if you delete any of the renamed functions.
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.
Commented on a couple more renamings/tiny refactorings I think would be worthwhile, but would like confirmation on. I could comment on every rename, but I hope they are mostly self-explanatory.
src/inspector_agent.h
Outdated
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 this rename would make meaning more clear.
src/inspector_socket.cc
Outdated
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.
Perhaps I misunderstand node naming conventions, but I thought C++ functions were supposed to be CamelCase
, and only variables are supposed to be snake_case
.
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.
This class was a plain C as it was mimicking libuv conventions. Need to become proper C++ at some point...
src/inspector_socket.h
Outdated
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 found this confusing, it is a TCP connection, and it is connected to a "client" on the other side, but this side is the "server" side of the HTTP/Websocket connection. I'd suggest just calling it "tcp" (because it is a uv_tcp_t
) or "socket" (because it wraps a socket).
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.
tcp/socket - both sound good. Ultimately, I believe this field name came from libuv API uv_accept that calls the connection socket "client" as opposed to "server" that is a listening socket.
src/inspector_socket_server.cc
Outdated
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.
?
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.
Typo... AFAIR, they might've had _Io suffix at some point to signify they are called on IO thread.
src/inspector_socket_server.h
Outdated
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.
Am I missing something? It seems like most of the state is passed in the ctor, and then some is passed in Start(), and I don't see why, is it just historical? Is there some future use-case this is designed around?
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.
This is the part I want to cleanup the most. Did a couple of half-hearted attempts but never achieved the desired result. It is historical (this code started as a fork of old Debug thread) and also because creation and start were separate at some point (this code was a part of the inpsector Agent).
src/node.cc
Outdated
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.
Legacy... when all the debug code was deleted this function was left with its old pre-inspector name.
76d70ed
to
10c93cf
Compare
src/inspector_socket_server.h
Outdated
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.
This is the part I want to cleanup the most. Did a couple of half-hearted attempts but never achieved the desired result. It is historical (this code started as a fork of old Debug thread) and also because creation and start were separate at some point (this code was a part of the inpsector Agent).
src/inspector_socket_server.cc
Outdated
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.
Typo... AFAIR, they might've had _Io suffix at some point to signify they are called on IO thread.
src/inspector_socket.h
Outdated
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.
tcp/socket - both sound good. Ultimately, I believe this field name came from libuv API uv_accept that calls the connection socket "client" as opposed to "server" that is a listening socket.
src/inspector_socket.cc
Outdated
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.
This class was a plain C as it was mimicking libuv conventions. Need to become proper C++ at some point...
10c93cf
to
e36367d
Compare
ci: https://ci.nodejs.org/job/node-test-pull-request/8383/ @eugeneo @addaleax want to take another look? I backed out the statics. |
src/inspector_agent.h
Outdated
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.
Is this a typo/supposed to be are called by
? (Also, I’d just say methods
instead of APIs
– at least to me a single API is usually a set of methods or similar things)
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.
Thanks!
Pure refactor, makes no functional changes but the renaming helped me see more clearly what the relationship was between methods and variables. - Renamed methods to reduce number of slightly different names for the same thing ("thread" vs "io thread", etc.). - Added comments where it was useful to me.
ci was all green, I rebased and fixed the typo @addaleax commented on |
e36367d
to
8acf9db
Compare
New CI after rebase: https://ci.nodejs.org/job/node-test-pull-request/8417/ |
Pure refactor, makes no functional changes but the renaming helped me see more clearly what the relationship was between methods and variables. * Renamed methods to reduce number of slightly different names for the same thing ("thread" vs "io thread", etc.). * Added comments where it was useful to me. PR-URL: #13321 Reviewed-By: Eugene Ostroukhov <[email protected]> Reviewed-By: Anna Henningsen <[email protected]> Reviewed-By: James M Snell <[email protected]>
Landed in 26ab769 |
Thank you. |
Pure refactor, makes no functional changes but the renaming helped me see more clearly what the relationship was between methods and variables. * Renamed methods to reduce number of slightly different names for the same thing ("thread" vs "io thread", etc.). * Added comments where it was useful to me. PR-URL: #13321 Reviewed-By: Eugene Ostroukhov <[email protected]> Reviewed-By: Anna Henningsen <[email protected]> Reviewed-By: James M Snell <[email protected]>
@eugeneo What do you think? Its "cosmetic" in some ways, but the renaming helped me understand the code better. I've a couple open questions, I'll comment on my own PR to point them out.
Pure refactor, makes no functional changes but the renaming helped me
see more clearly what the relationship was between methods and
variables.
same thing ("thread" vs "io thread", etc.).
Checklist
make -j4 test
(UNIX), orvcbuild test
(Windows) passesAffected core subsystem(s)