Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

Created December 22, 2015 10:31
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save anonymous/750c341a3c4f808c472d to your computer and use it in GitHub Desktop.
Save anonymous/750c341a3c4f808c472d to your computer and use it in GitHub Desktop.
(defn m-dec [buf]
(io/decode utf-codec buf))
(defn channel-handler [ch]
(go-loop []
(try
(let [ch-data (<! ch) msg (m-dec ch-data)]
(println "->" msg)
(if (= msg "stop")
(throw (Exception. "my exception message"))))
(catch Exception e (prn "channel exception: " (.getMessage e))
(close! ch)
(prn "channel shutdown!")))
(recur)))
(defn channel-new []
(let [ch (chan)]
(channel-handler ch) ch))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment