conjure icon indicating copy to clipboard operation
conjure copied to clipboard

Clojure socket server support

Open SuperCuber opened this issue 1 year ago • 2 comments

Is it possible to support a Clojure Socket Server ?

I have code running on a remote k8s pod and I think the easiest way for me to attach a REPL session to that pod is to give it an environment variable and connect to the socket. I have no trouble connecting (and I can port-forward it to make the port appear locally) and even running ConjureConnect localhost:5555 works! But then sending a form hangs and no command really work properly :(

I assume lots of functionality is impossible to implement (like interruption) but it would be amazing to have rudimentary support for sending a form + current namespace information to the remote process.

SuperCuber avatar Jan 01 '25 16:01 SuperCuber

Personally, I'd recommend you add nREPL as a runtime dependency and start one of those, I've used that before to debug some prod things and it worked great. Although it does bring in a bunch of dependencies which might not be acceptable in some situations.

Socket REPLs are a neat idea because they're so simple, but that makes them pretty impractical as a dev tool. I found that they're better as a program to program communication channel that's built into the language instead of a developer tool.

They're also good as something you can netcat into to get a very bare bones REPL on a remote host in your terminal.

I actually wrote at length a few times about why nREPL is so much better for development than socket REPL or prepl but I can't find my comments / posts on the matter right now. Conjure originally worked with prepl (socket REPL + data wrappers for each message) in a previous iteration but I gave up on it, it was too limited. I even got some changes merged into Clojure to fix some issues with the prepl implementation!

So, if you absolutely need a socket REPL support, we can look at building a Clojure client that talks socket REPL, not nREPL (they're completely distinct and not interchangeable as is) but I'd advise against it. It'll be a whole new client that will be far less capable than the existing one.

I hope this helps somewhat!

Olical avatar Jan 15 '25 21:01 Olical

Thanks for the detailed reply!

I don't think adding nrepl as a runtime dependency is a great option since at my company by default we share the same image in production and test environment :/

I think a socket repl is the least intrusive way to connect to a running app from my setup. Thinking out loud, would be nice to have something similar to vim-slime - but with ability to send forms to that session instead. (and a keybind to send (in-ns) form inferred from current file) IIRC sending a piece of text into a terminal is easy enough, but I'd like to reuse keybinds like "eval root form" and logic that detects the current namespace... I wonder if it's better as a separate plugin or if this is just going to end up more effort than adding into Conjure.

I don't "absolutely need" it so don't feel pressured to implement this 😅

SuperCuber avatar Jan 21 '25 14:01 SuperCuber