Created
December 22, 2015 10:31
-
-
Save anonymous/750c341a3c4f808c472d to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(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