Skip to content

Commit

Permalink
(feat) added client support for slacker 0.14 base
Browse files Browse the repository at this point in the history
Signed-off-by: Ning Sun <sunng@about.me>
  • Loading branch information
sunng87 committed May 3, 2016
1 parent e08c24f commit 1a4c2c9
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 12 deletions.
14 changes: 6 additions & 8 deletions examples/slacker/example/cluster_client.clj
@@ -1,7 +1,7 @@
(ns slacker.example.cluster-client
(:use [slacker.common])
(:use [slacker.client.cluster])
(:use [slacker.client :only [close-slackerc]]))
(:use [slacker.client :only [close-slackerc shutdown-slacker-client-factory]]))

(def sc (clustered-slackerc "example-cluster" "127.0.0.1:2181"))

Expand All @@ -22,18 +22,16 @@
:grouping-results :map
:async? true
:callback (fn [e r]
(println r)))
(println "++++" r)))

(defn -main [& args]
(binding [*debug* true]
(println (timestamp))
(println (rand-ints 10))
(println @(async-timestamp)))

(dotimes [_ 100] (timestamp))

(println (echo 23))
(println (all-timestamp))
(async-timestamp)
(try (make-error) (catch Exception e (println "Expected exception:" (ex-data e))))

(close-slackerc sc)
(System/exit 0))
(shutdown-slacker-client-factory)
(shutdown-agents))
12 changes: 8 additions & 4 deletions src/slacker/client/cluster.clj
Expand Up @@ -304,10 +304,14 @@
grouping-exceptions*
target-servers)
cb-results (atom [])
sys-cb (fn [result]
(when (= (count (swap! cb-results conj result))
(count target-servers))
(cb (grouping-fn @cb-results))))]
target-servers-count (count target-servers)
sys-cb (when cb
(fn [excp data]
(when (= (count (swap! cb-results conj
{:cause excp :result data}))
target-servers-count)
(let [grouped-results (grouping-fn @cb-results)]
(cb (:cause grouped-results) (:result grouped-results))))))]
(if (empty? target-conns)
(doto (promise) (deliver (if (contains? call-options :unavailable-value)
{:result (:unavailable-value call-options)}
Expand Down

0 comments on commit 1a4c2c9

Please sign in to comment.