Stuart addresses two anti-patterns in your PRs. Perhaps I can help explain them.
Let's say we have a system that looks like this:
(defrecord DBConnection [])
(defrecord DBLayer [db-connection])
(defrecord AppLayer [db-layer])
We can construct a system thusly:
{:db-connection (->DBConnection ...)
:db-layer (->DBLayer ...)
:app-layer (->AppLayer ...)}
And start it up:
(def my-system (start-system system-map))
First of all, what you need to recognize is that every component now has it's dependencies assoc'ed into the component. So each component should only deal with it's local view of the system:
(defrecord AppLayer [db-layer]
IDoStuff
(do-stuff [this]
(print-data (get-data db-layer)
(get-data2 (:db-layer this)))
What should not happen is that the AppLayer should do this:
(print-data (:db-layer my-system))
If a component does this it now has access to the entire system, and that circumvents one of the reasons component was created, to help improve separation of concerns.
In your other example you're doing something like this:
(defrecord AppLayer [db-layer]
IDoStuff
(do-stuff [this]
(run-query (:db-conn db-layer) "select foo from bar")))
The problem with this is that AppLayer is assuming that the db-layer has a connection to the db. This also violates the separation of concerns. Instead AppLayer should include a db-connection as a dependency if it is needed by the app layer code.
So that sums up Stuart's two replies. a) don't touch the system from inside a component, the system map is only for starting and stopping the system, and to provide an entry point. b) don't reach into other components from a component
Timothy