Last active
March 15, 2018 07:15
-
-
Save mszajna/5dd272802b507710cd73c9818e37417d to your computer and use it in GitHub Desktop.
Clojure reloaded workflow without libraries
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
(extend-type Object | |
Closable | |
(.close [o] o)) | |
(defn closable-jetty [server] | |
(reify Closable (close [_] (.stop server)))) | |
(defn start [] | |
(let [system (promise)] | |
(future | |
(with-open [config (read (slurp "config.edn")) ; Via hack above | |
db-connection (open-connection (:db config)) | |
handler (make-handler db-connection) ; Via hack above | |
server (closable-jetty (run-jetty handler)) | |
stop (promise)] ; Via hack above | |
(deliver system {:config config | |
:db-connection db-connection | |
:handler handler | |
:server server | |
:stop (fn [] (deliver stop nil))}) | |
@stop)) | |
system)) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment