ztellman/lamina

Testing whether a channel is in error state

jarohen opened this issue · 3 comments

Hi Zach,

Thanks for a really useful library!

Is there an idiomatic way in Lamina to test whether a channel is in error? I was looking for something similar to lamina.core/closed? and lamina.core/drained? but couldn't find an lamina.core/error?.

(If not, I don't mind looking into writing one and submitting a pull request)

James

Hi again,

After a deeper look through the core docs, I've stumbled across lamina.core/drained-result, which is enough to solve my particular use case (solution below, if anyone's interested!). I'll leave this issue open for now though, just in case anyone else thinks it might be necessary/useful, otherwise please feel free to close.

James

(require '[lamina.core :as l])

(let [ch (l/channel)
      res (l/drained-result ch)]

  (l/on-realized res
                 (fn [_] (println "Successfully drained"))
                 (fn [e] (println "Error'd" e)))
  #_(l/close ch) ; would print "successfully drained"    
  (l/error ch "an error")) ; prints "Error'd an error"

There's actually a function called error-value which should be exposed in
lamina.core, but isn't. I'll remedy that now.

On Fri, Feb 8, 2013 at 4:35 AM, James Henderson notifications@github.comwrote:

Hi again,

After a deeper look through the core docs, I've stumbled across
lamina.core/drained-result, which is enough to solve my particular use
case (solution below, if anyone's interested!). I'll leave this issue open
for now though, just in case anyone else thinks it might be
necessary/useful, otherwise please feel free to close.

James

(let [ch (l/channel)
res (l/drained-result ch)]

(l/on-realized res
(fn _)
(fn [e](println "Error'd" e)))
#_(l/close ch) ; would print "successfully drained"
(l/error ch "an error")) ; prints "Error'd an error"


Reply to this email directly or view it on GitHubhttps://github.com//issues/56#issuecomment-13288575.

That's great, thanks!