start/stop don't call a component's start/stop when there is no dependencies in the system map...
jszakmeister opened this issue · 1 comments
I understand some of what is happening here, but was a bit thrown off by it. I was attempting to build a system map up piece by piece, and expected to see my component's start and stop methods to be called, but they weren't. I believe it's because I don't currently have any dependencies between the keys, but it seems like an oversight. Some of the components do need to create something on start, but that can't happen if start isn't called.
Here's a small example of the problem:
(require '[com.stuartsierra.component :as component])
(defrecord Queue [queue]
component/Lifecycle
(start [component]
(println "Starting queue...")
(assoc component :queue (clojure.lang.PersistentQueue/EMPTY)))
(stop [component]
(println "Stopping queue...")
(assoc component :queue nil)))
(defn new-queue []
(map->Queue {}))
(defn example-system []
(component/system-map
:queue (new-queue)))
;; This fails to call Queue's start method.
(component/start (example-system))
Unfortunately, I'm not sure what the best way of solving this problem is (I haven't dug deep enough into the code to really grasp what needs to be done to fix it). But I figured it was worth reporting.
This is not your fault--it appears to be an AOT-related issue. I was using gradle-clojure to compile and run the resulting uberjar, but I believe it's suffering from problems like: http://dev.clojure.org/jira/browse/CLJ-1544