refactoring (find-states) out to be public
This commit is contained in:
parent
fe78675d99
commit
8bbd3472af
2 changed files with 14 additions and 11 deletions
|
|
@ -31,13 +31,13 @@
|
||||||
(tn/refresh-all))
|
(tn/refresh-all))
|
||||||
|
|
||||||
(defn go
|
(defn go
|
||||||
"Initializes and starts the system running."
|
"starts all defstate.s"
|
||||||
[]
|
[]
|
||||||
(start)
|
(start)
|
||||||
:ready)
|
:ready)
|
||||||
|
|
||||||
(defn reset
|
(defn reset
|
||||||
"Stops the system, reloads modified source files, and restarts it."
|
"stops all defstates, reloads modified source files, and restarts defstates"
|
||||||
[]
|
[]
|
||||||
(stop)
|
(stop)
|
||||||
(tn/refresh :after 'dev/go))
|
(tn/refresh :after 'dev/go))
|
||||||
|
|
|
||||||
|
|
@ -52,6 +52,12 @@
|
||||||
(throw (RuntimeException. (str "could not stop [" name "] due to") t)))))
|
(throw (RuntimeException. (str "could not stop [" name "] due to") t)))))
|
||||||
(alter-meta! var assoc :started? false)))
|
(alter-meta! var assoc :started? false)))
|
||||||
|
|
||||||
|
(defn find-states []
|
||||||
|
(->> (all-ns)
|
||||||
|
(mapcat ns-interns)
|
||||||
|
(map second)
|
||||||
|
(filter #(= (:session-id (meta %)) session-id))))
|
||||||
|
|
||||||
;; TODO: narrow down by {:mount {:include-ns
|
;; TODO: narrow down by {:mount {:include-ns
|
||||||
;; {:starts-with ["app.foo" "bar.baz"]
|
;; {:starts-with ["app.foo" "bar.baz"]
|
||||||
;; :nss ["app.nyse" "app.tools.datomic"] }
|
;; :nss ["app.nyse" "app.tools.datomic"] }
|
||||||
|
|
@ -59,19 +65,16 @@
|
||||||
;; {:starts-with ["dont.want.this" "app.debug"]
|
;; {:starts-with ["dont.want.this" "app.debug"]
|
||||||
;; :nss ["dev" "app.stage"]}}}
|
;; :nss ["dev" "app.stage"]}}}
|
||||||
;;
|
;;
|
||||||
;; would come from lein dev profile
|
;; would come from boot/lein dev profile
|
||||||
(defn- f-states [f order]
|
(defn- bring [states fun order]
|
||||||
(->> (all-ns)
|
(->> states
|
||||||
(mapcat ns-interns)
|
|
||||||
(map second)
|
|
||||||
(filter #(= (:session-id (meta %)) session-id))
|
|
||||||
(sort-by (comp :order meta) order)
|
(sort-by (comp :order meta) order)
|
||||||
(map #(f % (meta %)))))
|
(map #(fun % (meta %)))))
|
||||||
|
|
||||||
(defn start []
|
(defn start []
|
||||||
(doall
|
(doall
|
||||||
(f-states up <)))
|
(bring (find-states) up <)))
|
||||||
|
|
||||||
(defn stop []
|
(defn stop []
|
||||||
(doall
|
(doall
|
||||||
(f-states down >)))
|
(bring (find-states) down >)))
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue