Permalink
Browse files

create-sevak-from-fn resolves function vars

  • Loading branch information...
amitrathore committed Nov 25, 2010
1 parent a4fc60e commit f0ab7c6b1d7c737c994aab392159d0d235d9acfc
Showing with 10 additions and 9 deletions.
  1. +3 −9 src/org/runa/swarmiji/sevak/sevak_core.clj
  2. +7 −0 src/org/runa/swarmiji/utils/general_utils.clj
@@ -17,13 +17,6 @@
(def START-UP-REPORT "START_UP_REPORT")
(def SEVAK-SERVER "SEVAK_SERVER")
-(defn ns-qualified-name
- ([sevak-name-keyword the-name-space]
- (str (ns-name the-name-space) "/" (name sevak-name-keyword))))
-
-(defn sevak-info [sevak-name realtime? needs-response? function]
- {:name sevak-name :return needs-response? :realtime realtime? :fn function})
-
(defn register-sevak [sevak-name function-info]
(dosync
(alter sevaks assoc sevak-name function-info)))
@@ -39,10 +32,11 @@
(defmacro create-sevak-from-function
([function realtime? needs-response?]
- (let [sevak-name-keyword (keyword function)]
+ (let [{:keys [ns name]} (meta (resolve function))
+ sevak-name-keyword (keyword name)]
`(do
(register-sevak (ns-qualified-name ~sevak-name-keyword *ns*) (sevak-info ~sevak-name-keyword ~realtime? ~needs-response? ~function))
- (def ~function (sevak-runner ~realtime? ~sevak-name-keyword ~needs-response?)))))
+ (def ~name (sevak-runner ~realtime? ~sevak-name-keyword ~needs-response?)))))
([function]
(create-sevak-from-function function true true)))
@@ -9,6 +9,13 @@
(defn random-uuid []
(str (UUID/randomUUID)))
+(defn ns-qualified-name
+ ([sevak-name-keyword the-name-space]
+ (str (ns-name the-name-space) "/" (name sevak-name-keyword))))
+
+(defn sevak-info [sevak-name realtime? needs-response? function]
+ {:name sevak-name :return needs-response? :realtime realtime? :fn function})
+
(defn return-queue-name [sevak-name]
(str (System/currentTimeMillis) "_" sevak-name "_" (random-uuid)))

0 comments on commit f0ab7c6

Please sign in to comment.