-
-
Save dball/cd2c0b73df3608459f71428f3c9f90f0 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(defn find-dependencies | |
[system roots] | |
(let [graph (component/dependency-graph system roots) | |
dependencies (into #{} (mapcat (:dependencies graph) roots))] | |
(-> #{} | |
(into roots) | |
(into dependencies) | |
(cond-> (seq dependencies) | |
(into (find-dependencies system dependencies)))))) | |
(defn sub-system | |
[system roots] | |
(let [all (set (keys system)) | |
dependencies (find-dependencies system roots) | |
unnecessary (disj (set/difference all dependencies) :config)] | |
(apply dissoc system unnecessary))) | |
(defn create-system | |
[config roots decrypters] | |
(let [dependencies (build-dependencies config)] | |
(-> (build-system config decrypters) | |
(component/system-using dependencies) | |
(sub-system roots)))) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment