Skip to content

Commit 3f0cfa6

Browse files
committed
clojure balancer result api for #286
1 parent 09b3753 commit 3f0cfa6

File tree

1 file changed

+12
-0
lines changed

1 file changed

+12
-0
lines changed

src/clojure/nginx/clojure/core.clj

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -339,3 +339,15 @@ When a message comes the callback function will be invoked. e.g.
339339
(callback message att))))]
340340
(fn [] (.unsubscribe topic pd))))
341341
(destory! [topic] (.destory topic)))
342+
343+
(defn balancer-result
344+
"Build a balancer result for a load balancer.
345+
`idx-or-url can be an index of the upstream servers list or the url string.
346+
e.g. (balancer-result 3) , (balancer-result \"192.168.3.5:8071\")
347+
"
348+
[idx-or-url]
349+
(cond
350+
(instance? String idx-or-url) {:status 200, :body idx-or-url}
351+
(instance? Integer idx-or-url) {:status 200, :body idx-or-url}
352+
:else
353+
{:status 500}))

0 commit comments

Comments
 (0)