diff --git a/circle.yml b/circle.yml index e3cccfc..e8bbe1d 100644 --- a/circle.yml +++ b/circle.yml @@ -4,7 +4,7 @@ machine: dependencies: pre: - - wget https://github.com/boot-clj/boot-bin/releases/download/2.4.2/boot.sh + - wget https://github.com/boot-clj/boot-bin/releases/download/2.5.2/boot.sh - mv boot.sh boot && chmod a+x boot && sudo mv boot /usr/local/bin test: diff --git a/src/mount/core.cljc b/src/mount/core.cljc index e8e70d4..41e0152 100644 --- a/src/mount/core.cljc +++ b/src/mount/core.cljc @@ -302,11 +302,3 @@ (defn resume [& states] (let [states (or (seq states) (all-without-subs))] {:resumed (bring states sigcont <)})) - -(defn system [] ;; if/when lift vars, will be in a "system-mode" later - (let [sys @meta-state] - (into {} - (for [[k {:keys [inst var]}] sys] - [(unvar-state k) (if (= :cljc @mode) - @inst - @var)])))) diff --git a/src/mount/system.clj b/src/mount/system.clj deleted file mode 100644 index 808093b..0000000 --- a/src/mount/system.clj +++ /dev/null @@ -1,75 +0,0 @@ -(ns mount.system - (:require [mount.core :as mount])) - -(defprotocol Lifecycle - (start [this] "starts a system") - (stop [this] "stops a system") - ;; (start-with [this states]) - ;; (start-without [this states]) - ;; (stop-except [this states]) - ) - -(defrecord MountSystem [components]) - -(defn- select-fun [states f] - (into [] - (for [[name state] states] - (when-let [fun (f state)] - [name fun])))) - -(defn- bring-system [funs] - (into {} - (for [[name fun] funs] - [name (fun)]))) - -(defn- unvar-state [s] - (->> s (drop 2) (apply str))) ;; magic 2 is removing "#'" in state name - -(defn unvar-names [states] - (into {} (for [[k v] states] - [(unvar-state k) v]))) - -(defn- not-started [states] - (into {} - (for [state (keys states)] - [state :not-started]))) - -(defn- detach [sys] - (doseq [[state {:keys [var status] :as v}] sys] - (alter-var-root var (constantly :not-started)) - (#'mount.core/update-meta! [state :status] #{:stopped}) - (#'mount.core/update-meta! [state :var] :not-started))) - -(defn- attach [sys] - (into {} - (for [[k {:keys [var]}] sys] - [(unvar-state k) @var]))) - -(defn- spawn [sys] - (mount/start) - (let [spawned (attach sys)] - (detach sys) - spawned)) - -(defn new-system [meta-state] - (let [states (-> (sort-by (comp :order val) < - meta-state) - unvar-names) - down (reverse (select-fun states :stop))] - (extend-type MountSystem - Lifecycle - (start [states] (->MountSystem (spawn meta-state))) - (stop [_] (bring-system down))) - (->MountSystem (not-started states)))) - -(comment - -(require :reload '[mount.system :as m]) -(def ms @@#'mount.core/meta-state) -(def sys (new-system ms)) -(def sys (m/start sys)) - -;; at this point the system is up and detached: i.e. "global" vars and mount do not see it -;; TODO: figure out stopping it.. i.e. need to convert stops to work with @deps -;; ... quite possible in "cljc" :) -)