riemann - clojure.lang.LazySeq cannot be cast to clojure.lang.IFn -


i'm new riemann , clojure. want send email notifications 3 email groups when service's ttl expired. created sort of config file store list of emails:

{   :email_group_1 (                   "first@example.com"                   "second@example.ru"                  )   :email_group_2 (                   "third@example.com"                  ) } 

my riemann config looks this:

(logging/init {:console true}) (import org.apache.log4j.level) (logging/set-level level/debug)  (require '[clojure.java.io :as io]) (import '[java.io pushbackreader])  (let [host "0.0.0.0"]   (tcp-server {:host host :port 60001})   (udp-server {:host host})   (ws-server  {:host host :port 60003})) (repl-server  {:host "127.0.0.1"})  (def cwd (system/getproperty "user.dir"))  (def emails   (with-open [r (io/reader (str cwd "/etc/emails.clj"))]              (read (pushbackreader. r))))  (periodically-expire 5)  (def email (mailer))  (defn notify [& egroups]   (for [egroup egroups]     (rollup 1 60 (apply email (emails egroup)))))  (let [index (index)]   (streams     (default :ttl 60       index        (expired           (where (service "service_connect_active")                     #(info "expired" %)                     (notify :email_group_1 :email_group_2)))))) 

code looks (for me), when service expired following error:

09:45:39 riemann.1      | info [2015-05-08 10:45:39,313] thread-5 - riemann.config - expired {:ttl 60, :time 357766884827/250, :state expired, :service service_connect_active, :host ava.local} 09:45:39 riemann.1      | warn [2015-05-08 10:45:39,319] thread-5 - riemann.config - clojure.lang.lazyseq@841649b8 threw 09:45:39 riemann.1      | java.lang.classcastexception: clojure.lang.lazyseq cannot cast clojure.lang.ifn 09:45:39 riemann.1      |   @ riemann.config$eval66$stream__70$fn__75.invoke(riemann.development.config:34) 09:45:39 riemann.1      |   @ riemann.config$eval66$stream__70.invoke(riemann.development.config:45) 09:45:39 riemann.1      |   @ riemann.streams$match$stream__3514$fn__3525.invoke(streams.clj:1209) 09:45:39 riemann.1      |   @ riemann.streams$match$stream__3514.invoke(streams.clj:1209) 09:45:39 riemann.1      |   @ riemann.streams$default$stream__3731$fn__3742.invoke(streams.clj:1328) 09:45:39 riemann.1      |   @ riemann.streams$default$stream__3731.invoke(streams.clj:1328) 09:45:39 riemann.1      |   @ riemann.core$stream_bang_$fn__4415.invoke(core.clj:19) 09:45:39 riemann.1      |   @ riemann.core$stream_bang_.invoke(core.clj:18) 09:45:39 riemann.1      |   @ riemann.core$reaper$worker__4529$fn__4539.invoke(core.clj:303) 09:45:39 riemann.1      |   @ riemann.core$reaper$worker__4529.invoke(core.clj:297) 09:45:39 riemann.1      |   @ riemann.service.threadservice$thread_service_runner__1973$fn__1974.invoke(service.clj:71) 09:45:39 riemann.1      |   @ riemann.service.threadservice$thread_service_runner__1973.invoke(service.clj:70) 09:45:39 riemann.1      |   @ clojure.lang.afn.run(afn.java:22) 09:45:39 riemann.1      |   @ java.lang.thread.run(thread.java:745) 

could please me? thanks.

the "cannot cast clojure.lang.ifn" error invariably points expecting function being given cannot treated such...

(defn notify [& egroups]   (for [egroup egroups]     (rollup 1 60 (apply email (emails egroup))))) 

this returns for-generated lazyseq of rollup streams, not actual stream (in riemann stream is-an ifn). when riemann tries invoke stream ifn error occurs...

how like:

(defn notify [& egroups]   (rollup 1 60 (apply email (mapcat emails egroups)))) 

here convert list of groups list of emails upfront , on our lives.

alternatively if want multiple streams (avoiding shared to: lines example), apply them rollup.

(defn notify [& egroups]   (apply rollup 1 60 (map email (map emails groups)))) 

hope helps, don't have whole config replicated.


Comments