Last active
April 22, 2019 21:40
-
-
Save hiredman/a9e92a72c152047244fbd2cee78d14b2 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
;; clj -J-Xmx32m -Sdeps '{:deps {org.jgroups/jgroups {:mvn/version "4.0.12.Final"}}}' | |
(defn server [] | |
(let [channel (org.jgroups.JChannel.) | |
_ (.connect channel "clojure-eval") | |
_ (.setReceiver | |
channel | |
(proxy [org.jgroups.ReceiverAdapter] [] | |
(receive [msg-batch] | |
(doseq [msg (.array msg-batch) | |
:let [msg (.getObject msg)]] | |
(case (:op msg) | |
:eval (.send channel (org.jgroups.Message. | |
nil | |
{:op :response | |
:form (eval (:form msg))})) | |
:response (prn (:form msg)))))))] | |
(fn | |
([] | |
(.close channel)) | |
([form-to-eval] | |
(.send channel | |
(org.jgroups.Message. nil | |
{:op :eval :form form-to-eval})))))) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment