Skip to content
This repository has been archived by the owner on Apr 9, 2024. It is now read-only.

Commit

Permalink
Changed look-up to allow for configurable remote address
Browse files Browse the repository at this point in the history
  • Loading branch information
gaverhae committed Jul 17, 2012
1 parent 2d41c2c commit 7580215
Showing 1 changed file with 13 additions and 2 deletions.
15 changes: 13 additions & 2 deletions src/okku/core.clj
Expand Up @@ -66,9 +66,20 @@
(if n `(.actorOf ~c ~p ~n)
`(.actorOf ~c ~p))))

(defn look-up [address & {s :in}]
(defn look-up [address & {s :in n :name}]
(if-not s (throw (IllegalArgumentException. "okku.core/look-up needs an :in argument")))
(.actorFor s address))
(let [[prot sys hn port & path] (clojure.string/split address #"://|@|:|/")
{cprot "protocol" csys "actor-system" chn "hostname" cport "port"
cpath "path"} (get-in (.root (.. s settings config)) ["okku" "lookup" (str "/" n)])
[cprot csys chn cport cpath] (map #(if % (.unwrapped %)) [cprot csys chn cport cpath])
path (clojure.string/join "/" path)
cpath (if cpath (if (= (first path) \/) cpath (str "user/" cpath)))
address (str (or cprot prot) "://"
(or csys sys) "@"
(or chn hn) ":"
(or cport port) "/"
(or cpath path))]
(.actorFor s address)))

(defmacro stop []
'(.stop (.getContext this) (.getSelf this)))
Expand Down

0 comments on commit 7580215

Please sign in to comment.