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

Embedding gorilla-repl #227

Open
deas opened this issue Oct 30, 2015 · 7 comments
Open

Embedding gorilla-repl #227

deas opened this issue Oct 30, 2015 · 7 comments

Comments

@deas
Copy link
Collaborator

deas commented Oct 30, 2015

I am just poking around with gorilla-repl and its seems it is not far away from being "cleanly" embeddable.

Would you be interested to see a PR with those changes?

@JonyEpsilon
Copy link
Owner

Oddly enough, I was just playing around myself with embedding Gorilla in a Java application! I changed the build so it generates a main class in the jar (see 75e6435) and it seems to work ok.

What changes are you thinking?

@deas
Copy link
Collaborator Author

deas commented Oct 31, 2015

Decoupling it from httpkit, Feeding the repl using a javax.websocket.server.ServerEndpoint, adding a Servlet class (dispatching to the compojure handler) to be dropped in using a web-fragment.xml, allowing configuration of handler paths, and allowing an externally configured nrepl server.

Guess the difference of my embedding approach is that I don't want it to bring it's own server (jetty) or nrepl and want to use what's already there. Using your own port (in production) may also have the drawback that it won't be reachable due to firewalls and things along those lines.

Got most of that working. The last missing piece seems to be a nrepl transport dispatching from the ServerEndpoint to the repl. Somewhat similar to the current httpkit based relaying code.

@JonyEpsilon
Copy link
Owner

I see, that sounds interesting. I'm generally quite conservative as I like to keep the code simple, and my initial thought is that this might add quite a bit of extra complexity. But if there's a way we can break it out so that Gorilla itself stays simple but offers up some extension points for embedding then it would be a good thing.

@deas
Copy link
Collaborator Author

deas commented Nov 6, 2015

Don't worry. The changes that "should" go in gorilla repl are fairly small and do imho even improve the code by separating out concerns such as httpkit which one might want to :exclude if you are embedding in another app.

If we want to provide an aotd Ring Servlet, its web-fragment.xml and @serverendpoint along with gorilla-repl might be debatable. Personally, I am aiming for a generic "uberjar drop-in" allowing you to "inject" gorilla-repl in virtually any webapp, but I don't have to drop "all" the code in here. :)

Not strictly an embedding issue, but I also replaced the connection atom and bypass the network layer when calling into nrepl.

@JonyEpsilon
Copy link
Owner

Sounds good. Do you want to put up a PR with these changes in for discussion when ready?

@deas
Copy link
Collaborator Author

deas commented Nov 11, 2015

I am just writing a blogpost about it. Will let you know about it. And will get back with more PRs for sure!

@narkisr
Copy link

narkisr commented Feb 19, 2017

Any plan on implementing this?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants