(ns clj-test.core
  (:require [com.stuartsierra.component :as component]))
            


(defrecord Config []
  component/Lifecycle

  (start [component]
    (println "Starting config")
    :conf1)

  (stop [component]
    (println "Stopping config"))
)

(defrecord Web [config]
  component/Lifecycle

  (start [component]
    (println "Starting web" config)
    :web1)

  (stop [component]
    (println "Stopping web"))
)

(defn create-system []
 (component/system-map
      :web (component/using
             (map->Web {})
             [:config])

      :config (map->Config {})))


(def system (create-system))

(defn start-all []
  (alter-var-root #'system component/start-system))
  
(defn stop-all []
  (alter-var-root #'system component/stop-system))
