Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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
cmd/dlv: add --client-addr flag to run dap with a predefined client #2568
cmd/dlv: add --client-addr flag to run dap with a predefined client #2568
Changes from 3 commits
cbfed32
e6f72d2
6538d62
d974e4d
596c5ba
fa0574a
4664030
d818a10
962ccae
104d76b
e58f24b
File filter
Filter by extension
Conversations
Jump to
There are no files selected for viewing
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 reminded me of the preconnected Listener used by the rpc server. In non-headless (basically with-client) mode, even though the client connection is predefined, the server code is reused as-is. Is something similar perhaps to consider here to arrive at a less nuanced common server denominator?
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.
Sorry, I don't understand what you mean. There is nothing special here beyond the standard basic tcp connection and I don't see much of commonality beyond that.
preconnected Listener is used to arrange the dlv cli to connect to the server (possibly running in process). There, the client is still a client (the role in the rpc protocol) and the server is what uses service/debugger package. In this reverse mode, the entity that is dialing and plays the role of 'server' in the protocol, is what's using service/debugger package.
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.
In my understanding, the client is the entity that makes the debugging requests and the server is the entity that serves those requests. I don't think it matters which side connects to which side, client to server or server to client. Regardless of the specifics of that initial handshake, the rest of the traffic and meaning of the two sides don't change, do they? That's true for both rpc+terminal case and for dap+special-client case.
In this new mode you are defining, you have a predefined client that you connect to before you call NewServer.
In case of the rpc server + terminal client, we also have a client connection that is predefined and pre-connected before newServer is called. Yet newServer still takes a listener, but that listener is fake. The listener doesn't actually listen as it is already pre-connected to the connection point that was already set up. On the very first call to Accept it will return that pre-existing client connection. And because of that abstraction, newServer and Run can be re-used as-is without any special logic or comments inside of the server itself.
I propose that we do the same here to move connection details outside of the server, keeping it general and consistent with the rpc server, which we ultimately want to merge with under a single command.
listenerpipe.go
hasListenerPipe
+ genericpreconnectedListener
, which you can reuse more or less ass-is. You can define something like this:Then pass the result to
NewServer
and not need to modify the dap server code.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 the proposed approach overcomplicates the code without clear use cases. When the use case that benefits from it is obvious, I am ok to rework this. Until then, I prefer simplicity and less channels and locks.