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))
|
||||
|
||||
(defn go
|
||||
"Initializes and starts the system running."
|
||||
"starts all defstate.s"
|
||||
[]
|
||||
(start)
|
||||
:ready)
|
||||
|
||||
(defn reset
|
||||
"Stops the system, reloads modified source files, and restarts it."
|
||||
"stops all defstates, reloads modified source files, and restarts defstates"
|
||||
[]
|
||||
(stop)
|
||||
(tn/refresh :after 'dev/go))
|
||||
|
|
|
|||
|
|
@ -52,6 +52,12 @@
|
|||
(throw (RuntimeException. (str "could not stop [" name "] due to") t)))))
|
||||
(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
|
||||
;; {:starts-with ["app.foo" "bar.baz"]
|
||||
;; :nss ["app.nyse" "app.tools.datomic"] }
|
||||
|
|
@ -59,19 +65,16 @@
|
|||
;; {:starts-with ["dont.want.this" "app.debug"]
|
||||
;; :nss ["dev" "app.stage"]}}}
|
||||
;;
|
||||
;; would come from lein dev profile
|
||||
(defn- f-states [f order]
|
||||
(->> (all-ns)
|
||||
(mapcat ns-interns)
|
||||
(map second)
|
||||
(filter #(= (:session-id (meta %)) session-id))
|
||||
;; would come from boot/lein dev profile
|
||||
(defn- bring [states fun order]
|
||||
(->> states
|
||||
(sort-by (comp :order meta) order)
|
||||
(map #(f % (meta %)))))
|
||||
(map #(fun % (meta %)))))
|
||||
|
||||
(defn start []
|
||||
(doall
|
||||
(f-states up <)))
|
||||
(bring (find-states) up <)))
|
||||
|
||||
(defn stop []
|
||||
(doall
|
||||
(f-states down >)))
|
||||
(bring (find-states) down >)))
|
||||
|
|
|
|||
Loading…
Reference in a new issue