Skip to content

Instantly share code, notes, and snippets.

@hiredman
Last active April 22, 2019 21:40
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save hiredman/a9e92a72c152047244fbd2cee78d14b2 to your computer and use it in GitHub Desktop.
Save hiredman/a9e92a72c152047244fbd2cee78d14b2 to your computer and use it in GitHub Desktop.
;; 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