Code Monkey home page Code Monkey logo

nrepl-server's Introduction

nrepl-server

Proof of concept nREPL server for something that may end up in babashka. Mostly a port of ogion.

Run

$ clojure -m borkdude.nrepl-server
Starting on port 1667

Connect with your favorite nREPL client:

$ rep -p 1667 '(+ 1 2 3)'
6

Reverse engineering the nREPL protocol

When developing the server, it's useful to inspect messages that are sent back and forth between existing implementations.

E.g., start a lein nREPL server:

$ lein repl
nREPL server started on port 56132 on host 127.0.0.1 - nrepl://127.0.0.1:56132

From CIDER connect with cider-connect and watch the *nrepl-messages* buffer. See the CIDER docs.

With Calva:

And connect to it with the development version of Calva.

To inspect messages, we're going to add some logging to src/nrepl/index.ts:

write(data: any) {
    console.log("write ->", data);
    ...
}
_response(data: any) {
    console.log("response ->", data);
    ...
}

Build Calva (npm install + run build task in VSCode) and run the extension in debug mode (Run > Start Debugging).

Via the command palette, select Calva: connect to a running REPL server outside project.

Behold:

write ->
Object
op
"clone"
session
"2699f4ad-b917-4224-a879-a5bfc8273a57"
id
"4"
response ->
Object
id
"4"
new-session
"310e3c0b-2607-4490-ad14-b1a04cb614d9"
session
"2699f4ad-b917-4224-a879-a5bfc8273a57"
status
Array[1]
0
"done"
write ->
Object
op
"eval"
session
"310e3c0b-2607-4490-ad14-b1a04cb614d9"
code
"(+ 1 1)"
id
"5"
pprint
false
response ->
Object
id
"5"
ns
"user"
session
"310e3c0b-2607-4490-ad14-b1a04cb614d9"
value
"2"
response ->
Object
id
"5"
session
"310e3c0b-2607-4490-ad14-b1a04cb614d9"
status
Array[1]
0
"done"

References

nrepl-server's People

Contributors

borkdude avatar

Stargazers

Crosstyan avatar Jakub Arnold avatar Jasper Humphrey avatar Maor Kadosh avatar  avatar Luiz Rodrigo de Souza avatar Delon R. Newman avatar Sameer Kolhar avatar Chris Zheng avatar Chris Badahdah avatar Mike Rodriguez avatar

Watchers

James Cloos avatar  avatar

Forkers

kolharsam

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.