Created
December 22, 2015 11:19
-
-
Save anonymous/e29755d17bafda438300 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 [] | |
(let [ch-data (<! ch) ] | |
(try | |
(let [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!"))) | |
(if-not (= ch-data nil) | |
(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