aboutsummaryrefslogtreecommitdiffhomepage
path: root/README.md
diff options
context:
space:
mode:
authorCalvin Rose <calsrose@gmail.com>2020-04-28 19:36:31 -0500
committerCalvin Rose <calsrose@gmail.com>2020-04-28 19:36:31 -0500
commitb94afb3aba6f8523137de1b97a90b3e878d9eb6a (patch)
tree633646b87e751f51fadb79d46e51e78a88929c40 /README.md
First commit.
Diffstat (limited to 'README.md')
-rw-r--r--README.md72
1 files changed, 72 insertions, 0 deletions
diff --git a/README.md b/README.md
new file mode 100644
index 0000000..f132387
--- /dev/null
+++ b/README.md
@@ -0,0 +1,72 @@
+# Spork
+
+Various Janet utility modules.
+
+## Message Protocol
+
+Provide a symmetric way to send and receive seqential messages over a networked stream.
+Useful for building more complicated application level protocols on top of TCP.
+
+```
+(import spork/msg)
+
+(def stream (net/connect "http://example.com" "1234"))
+
+(def send (msg/make-send stream))
+(def recv (msg/make-recv stream))
+
+(send "blob1")
+(def blob-respose (recv))
+```
+
+## Networked REPL
+
+Launch a networked REPL server on one machine and connect to it from another machine or process.
+
+### Server
+```
+(import spork/netrepl)
+
+(def some-def 10)
+
+# Serve a repl into the current environment (some-def will be visible)
+(netrepl/server "127.0.0.1" "9000" (fiber/getenv (fiber/current)))
+```
+
+### Client
+```
+(import spork/netrepl)
+
+# Starts a nice terminal repl.
+(netrepl/client "127.0.0.1" "9000" "bob")
+```
+
+## RPC Protocol
+
+A simple remote procedure call tool for Janet.
+
+### Server
+```
+(import spork/rpc)
+
+(def functions
+ @{:print (fn [x] (print "remote print: " x))
+ :add (fn [& xs] (sum xs))})
+
+(rpc/server "127.0.0.1 "9001")
+```
+
+### Client
+```
+(import spork/rpc)
+
+(def c (rpc/client "127.0.0.1" "9001" "joe"))
+
+# Will print on server
+(:print c "Hello from client!")
+
+(:add c 1 3 5 7 9) # -> 25
+
+# Close the underlying connection
+(:close c)
+```