Last active
October 1, 2015 19:20
-
-
Save eneroth/f52dab6943a17e2e56e0 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
;; Load config | |
(defn load-config [config-path] | |
(let [ch (chan)] | |
(go | |
(let [{:keys [succeeded data]} (<! (path/resolve config-path)) | |
abs-path data] | |
(if-not succeeded | |
(failure ch data (str "load-config: couldn't resolve path '" config-path "'")) | |
(let [{:keys [succeeded data]} (<! (file/read abs-path :utf-8)) | |
config-content data] | |
(if-not succeeded | |
(failure ch data (str "load-config: could not read the config from location '" config-path "'")) | |
(let [{:keys [succeeded data]} (<! (edn/parse config-content))] | |
(if-not succeeded | |
(failure ch data (str "load-config: couldn't parse config content.") config-content) | |
(success ch data)))))))) | |
ch)) |
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
;; Load config | |
(defn load-config [config-path] | |
(let [ch (chan)] | |
(go-work ch | |
[abs-path (path/resolve config-path) (str "load-config: couldn't resolve path '" config-path "'") | |
config-content (file/read abs-path :utf-8) (str "load-config: could not read the config from location '" config-path "'") | |
edn (edn/parse config-content) "load-config: couldn't parse config content."] | |
(success ch data)) | |
ch)) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment