Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixed issue #811 :can't define overload functions in hystrix-clj. #812

Merged
merged 1 commit into from
Jun 10, 2015
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -408,12 +408,15 @@
[name & opts]
(let [command-key (str *ns* "/" name )
group-key (str *ns*)
[m [params & body]] (split-def-meta opts)
[m body] (split-def-meta opts)
params (if (vector? (first body))
(list (first body))
(map first body))
m (if-not (contains? m :arglists)
(assoc m :arglists `(list (quote ~params)))
(assoc m :arglists `(quote ~params))
m)]
`(let [meta-options# (#'com.netflix.hystrix.core/extract-hystrix-command-options ~m)
run-fn# (fn ~name ~params ~@body)
run-fn# (fn ~name ~@body)
command-map# (com.netflix.hystrix.core/command (merge {:command-key ~command-key
:group-key ~group-key
:run-fn run-fn# }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -301,6 +301,15 @@
[a b]
(+ a b))

(defcommand my-overload-fn-command
"A doc string"
{:meta :data
:hystrix/fallback-fn (constantly 500)}
([a b]
(+ a b))
([a b c]
(+ a b c)))

(deftest test-defcommand
(let [hm (-> #'my-fn-command meta :hystrix)]
(testing "defines a fn in a var"
Expand All @@ -318,7 +327,24 @@
(is (= 105 (wait-for-observable (observe-later #'my-fn-command 91 14))))
(is (= 107 (wait-for-observable (observe-later-on #'my-fn-command
(rx.schedulers.Schedulers/newThread)
92 15)))))))
92 15)))))
(testing "overload functioning command"
(is (= 99 (my-overload-fn-command 88 11)))
(is (= 100 (my-overload-fn-command 88 11 1)))
(is (= 100 (execute #'my-overload-fn-command 89 11)))
(is (= 100 (execute #'my-overload-fn-command 88 11 1)))
(is (= 101 (deref (queue #'my-overload-fn-command 89 12))))
(is (= 102 (deref (queue #'my-overload-fn-command 89 12 1))))
(is (= 103 (wait-for-observable (observe #'my-overload-fn-command 90 13))))
(is (= 104 (wait-for-observable (observe #'my-overload-fn-command 90 13 1))))
(is (= 105 (wait-for-observable (observe-later #'my-overload-fn-command 91 14))))
(is (= 106 (wait-for-observable (observe-later #'my-overload-fn-command 91 14 1))))
(is (= 107 (wait-for-observable (observe-later-on #'my-overload-fn-command
(rx.schedulers.Schedulers/newThread)
92 15))))
(is (= 108 (wait-for-observable (observe-later-on #'my-overload-fn-command
(rx.schedulers.Schedulers/newThread)
92 15 1)))))))

(defcollapser my-collapser
"a doc string"
Expand Down