technomancy / leiningen

Moved to Codeberg; this is a convenience mirror
https://codeberg.org/leiningen/leiningen
Other
7.29k stars 1.61k forks source link

Support domain sockets in repl task #2781

Closed bbatsov closed 1 year ago

bbatsov commented 2 years ago

This ticket is mostly a reminder for myself to update the bundled nREPL server to the latest 0.9 version. Apart from just bumping the nREPL dep, it'd be nice to add support for starting the server in Unix domain mode (e.g. lein repl :socket nrepl.sock), as that'd result in better/safer local development experience and would allow us to do cider-jack-in with Unix sockets as well.

The required changes are very simple, so if anyone is very eager about them - feel free to beat me to making them. :)

technomancy commented 2 years ago

Can you clarify what you mean by lein repl :socket nrepl.sock?

I think that the best way to interpret this would be as an option which would work with both the default mode of operation (start a server and connect a client to it) and with the :headless and :connect arguments. But we already support a :transport argument which seems like a good fit for this.

Could use a little more detail about the desired operation here.

bbatsov commented 2 years ago

Can you clarify what you mean by lein repl :socket nrepl.sock?

Start an nREPL server that's listing on this specified unix domain socket. Right now tools like CIDER doesn't have an easy way to jack-in directly into a unix socket powered REPL.

I think that the best way to interpret this would be as an option which would work with both the default mode of operation (start a server and connect a client to it) and with the :headless and :connect arguments. But we already support a :transport argument which seems like a good fit for this.

The problem is that the transport alone is not enough, as you still need to specific which socket to bind to. I was also thinking that if :socket is present Lein can simply infer that it needs to start/connect using the socket transport.

Admittedly, I didn't have time to look into the Lein codebase to provide some more concrete suggestions. I've created this ticket mostly as a reminder to implement some better support for unix sockets at some point.

bbatsov commented 2 years ago

I wrote a little bit more about the Unix socket support in nREPL here https://metaredux.com/posts/2021/12/12/nrepl-0-9.html

technomancy commented 2 years ago

Start an nREPL server that's listing on this specified unix domain socket

Ah, so it looks like one key factor I hadn't considered yet is that domain sockets are currently only supported in the server side, and not in the client in reply. So at present, starting a server is the only thing you can do with them.

However, if we use the suggested notation specifically for starting a server, that will complicate things later on if support is added to the client. That's why I think it's important that whatever we add should specifically be a flag we add to the :headless subcommand. That way we don't design ourselves into a corner later down the line, when ideally a regular client+server repl session can be started using domain sockets.

bbatsov commented 2 years ago

That's why I think it's important that whatever we add should specifically be a flag we add to the :headless subcommand.

That'd be fine by me.

technomancy commented 2 years ago

Thanks; I guess I just needed to think out loud to come to a solution.

technomancy commented 1 year ago

Should be taken care of by #2799