this repo has no description
1(def hosts [
2 {:name "claudius"
3 :ip "45.63.9.183"
4 :online true
5 :services
6 [{:name "janet.guide"}
7 {:name "bauble.studio"}
8 {:name "ianthehenry.com"}]}
9 {:name "caligula"
10 :ip "45.63.9.184"
11 :online false
12 :services [{:name "basilica.horse"}]}])
13
14(each host hosts
15 (if (host :online)
16 (each service (host :services)
17 (print (service :name)))))
18
19(loop [host :in hosts
20 :when (host :online)
21 service :in (host :services)]
22 (print (service :name)))
23
24(print)
25
26(each host hosts
27 (if (host :online)
28 (let [ip (host :ip)]
29 (eachp [service-name available] (host :services)
30 (if available
31 (for instance 0 3
32 (pp [ip service-name instance])))))))
33
34(loop [host :in hosts
35 :when (host :online)
36 :let [ip (host :ip)]
37 [service-name available] :pairs (host :services)
38 :when available
39 instance :range [0 3]]
40 (pp [ip service-name instance]))