Skip to content

Instantly share code, notes, and snippets.

@mszajna
Last active March 15, 2018 07:15
Show Gist options
  • Save mszajna/5dd272802b507710cd73c9818e37417d to your computer and use it in GitHub Desktop.
Save mszajna/5dd272802b507710cd73c9818e37417d to your computer and use it in GitHub Desktop.
Clojure reloaded workflow without libraries
(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