Skip to content
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

Add and populate :host and :socket keys on nrepl.server.Server #311

Merged
merged 3 commits into from Feb 20, 2024

Conversation

chancerussell
Copy link
Contributor

Like #310, but also provides the :host key.

This fixes an issue that occurs when using the --interactive option in concert with --socket PATH. Since the Server object has no :socket key, nrepl.cmdline/interactive-repl won't recognize that it should connect to the socket and will exit with an error message.

Also adjusts an existing test to exercise the code path in question.

Before submitting a PR make sure the following things have been done:

  • The commits are consistent with our contribution guidelines
  • You've added tests to cover your change(s)
  • All tests are passing
  • The new code is not generating reflection warnings
  • You've updated the changelog(that only applies to user-visible changes)

Thanks!

If you're just starting out to hack on nREPL you might find this section of its
manual
extremely useful.

@bbatsov
Copy link
Contributor

bbatsov commented Feb 7, 2024

@rlbdv Feel free to take a look as well.

@bbatsov
Copy link
Contributor

bbatsov commented Feb 8, 2024

Can you rebase on top of master?

This test currently passes a map of its own construction to run-repl, so
it's not testing the return value from start-server, and doesn't catch
the issue described at nrepl#309 .
This fixes an issue that occurs when using the `--interactive` option in
concert with `--socket PATH`. Since the Server object has no :socket
key, nrepl.cmdline/interactive-repl won't recognize that it should
connect to the socket and will exit with an error message.

This also ensures that consumers of the record can obtain the passed-in
host value.
@chancerussell chancerussell force-pushed the fix-interactive-with-socket-file branch from f860b9f to d625f01 Compare February 8, 2024 16:21
@chancerussell
Copy link
Contributor Author

Can you rebase on top of master?

Yep, just rebased!

@@ -158,7 +158,7 @@
(binding [dynamic-loader/*state* state]
((:handler @state) msg)))))

(defrecord Server [server-socket port open-transports transport greeting handler]
(defrecord Server [server-socket host port socket open-transports transport greeting handler]
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm wondering if here we shouldn't name this unix-socket, to differentiate from the server-socket. Not a big deal, but it might make things clearer for someone.

Or maybe we should add some docstring to this record to explain its purpose.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I will:

  • Add some explanatory comments to the defrecord form re: what the fields are supposed to mean (unfortunately, this won't be a docstring, since defrecrord doesn't support them)
  • Open an additional PR just like this one, but with the socket field renamed to unix-socket

And then I'll leave it to you all to choose which one you like better and let you update the comments as you wish :)

@bbatsov
Copy link
Contributor

bbatsov commented Feb 14, 2024

Can you, please, address the small indentation error detected by the lint job?

@chancerussell
Copy link
Contributor Author

I just opened #312, which is the same as this PR, but renames the :socket field to :unix-socket and updates the bits that look at that field to account for the change.

Personally, I would lean towards not renaming the key, since anyone providing their own custom repl-fn might have written it to expect a server object bearing the socket key, but you'd know better than me if that's likely to be an issue :)

(I also sort of want to say the key might be better named unix-socket-path or filesystem-socket-path, since it's not holding an actual socket object, but I could bikeshed on that for days!)

I'll be unavailable for a few days—please feel 100% free to make any desired changes you'd like against either PR to get this merged!

@bbatsov bbatsov merged commit 8c28e59 into nrepl:master Feb 20, 2024
19 checks passed
@bbatsov
Copy link
Contributor

bbatsov commented Feb 20, 2024

Personally, I would lean towards not renaming the key, since anyone providing their own custom repl-fn might have written it to expect a server object bearing the socket key, but you'd know better than me if that's likely to be an issue :)

Same. I was thinking more along the lines of duplicating the key and deprecating the old name, but it's not a big deal. I think this PR is enough for now.

@chancerussell chancerussell deleted the fix-interactive-with-socket-file branch February 26, 2024 02:41
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

--interactive doesn't work with --socket PATH
2 participants