Created
August 16, 2016 17:33
-
-
Save tacticiankerala/01f47bde7d1be576f11909d4be5e20d8 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
(defrecord Database [host port connection] | |
component/Lifecycle | |
(start [component] | |
(let [conn (connect-to-database host port)] | |
(assoc component :connection conn))) | |
(stop [component] | |
(.close connection) | |
(assoc component :connection nil))) | |
(defrecord Dashboard [database datasources options dashboard] | |
component/Lifecycle | |
(start [component] | |
(let [datasources-with-db (map #(assoc-in % [:params 0] database) datasources)] | |
(assoc component :dashboard (ds/start datasources-with-db options)))) | |
(stop [component] | |
(.stop dashboard) | |
(assoc component :dashboard nil))) | |
(def my-system (component/system-map | |
:database (map->Database {:host <host> :port <port>}) | |
:dashboard (component/using (map->Dashboard <datasources> <options>) [:database]))) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment