Skip to content

Instantly share code, notes, and snippets.

@hiredman

hiredman/jgroups.clj

Last active Apr 22, 2019
Embed
What would you like to do?
;; 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
You can’t perform that action at this time.