我对 clojure 很陌生,需要设置一个riemann配置,以便轻松编辑/添加新条件。我们现在拥有的:
(defn tell-ops
([to]
(by [:service]
(throttle 3 360
(rollup 2 360
slackerDefault
(email to)))))
([to channel]
(by [:service]
(throttle 3 360
(rollup 2 360
(slacker channel)
(email to))))))
............
(where (state "FATAL")
(where (service #"^Serv1")
(tell-ops "dev.ops1@foo.com" "#dev-ops1"))
(where (service #"^Serv2")
(tell-ops "dev.ops2@bar.com"))
....
)
此外,它缺少默认语句,例如 if nothing match, tell-ops "admin@fo.bar"
我想我需要像顶级结构这样的东西
(def services
[{:regex #"^serv1" :mail "foo@bar.com" :channel "#serv1"}
{:regex #"serv2$" :mail "foo@baz.com"} ])
这样很容易添加新的。但是我不知道如何在第二种情况下考虑到缺少 :channel 并在没有正则表达式匹配的情况下进行“默认调用”来循环该数组
提前致谢