Skip to content

Instantly share code, notes, and snippets.

@tacticiankerala
Created August 16, 2016 17:33
Show Gist options
  • Save tacticiankerala/01f47bde7d1be576f11909d4be5e20d8 to your computer and use it in GitHub Desktop.
Save tacticiankerala/01f47bde7d1be576f11909d4be5e20d8 to your computer and use it in GitHub Desktop.
(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