Skip to content

Commit 93584d8

Browse files
committed
Propagate worker-pod atom to pods created via make-pod
1 parent 1714ab6 commit 93584d8

File tree

2 files changed

+21
-6
lines changed

2 files changed

+21
-6
lines changed

boot/core/src/boot/task/built_in.clj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -123,7 +123,7 @@
123123

124124
[d debounce MSEC long "The time to wait (millisec) for filesystem to settle down."]
125125

126-
(.require @pod/worker-pod (into-array String ["boot.watcher"]))
126+
(pod/require-in-pod @pod/worker-pod "boot.watcher")
127127
(let [q (LinkedBlockingQueue.)
128128
srcdirs (->> (core/get-env :src-paths) (remove core/tmpfile?))
129129
watchers (map file/make-watcher srcdirs)

boot/pod/src/boot/pod.clj

Lines changed: 20 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -134,9 +134,13 @@
134134
out (io/output-stream (doto (io/file out-path) io/make-parents))]
135135
(io/copy in out)))
136136

137-
(def pod-id (atom nil))
138-
(def worker-pod (atom nil))
139-
(def shutdown-hooks (atom nil))
137+
(def pod-id (atom nil))
138+
(def worker-pod (atom nil))
139+
(def shutdown-hooks (atom nil))
140+
141+
(defn set-worker-pod!
142+
[pod]
143+
(reset! worker-pod pod))
140144

141145
(defn add-shutdown-hook!
142146
[f]
@@ -177,6 +181,10 @@
177181
[& body]
178182
`(eval-in @worker-pod ~@body))
179183

184+
(defn require-in-pod
185+
[pod ns]
186+
(doto pod (.require (into-array String [(str ns)]))))
187+
180188
(defn resolve-dependencies
181189
[env]
182190
(call-worker `(boot.aether/resolve-dependencies ~env)))
@@ -227,9 +235,16 @@
227235
(map (fn [[k v]] [v (.getPath (io/file outdir k))])))]
228236
(doseq [[url-str out-path] ents] (copy-url url-str out-path))))
229237

238+
(defn- set-this-worker-in-pod!
239+
[pod]
240+
(doto pod
241+
(require-in-pod "boot.pod")
242+
(.invoke "boot.pod/set-worker-pod!" @worker-pod)))
243+
230244
(defn make-pod
231-
([] (boot.App/newPod))
245+
([] (set-this-worker-in-pod! (boot.App/newPod)))
232246
([{:keys [src-paths] :as env}]
233247
(let [dirs (map io/file src-paths)
234248
jars (resolve-dependency-jars env)]
235-
(->> (concat dirs jars) (into-array java.io.File) (boot.App/newPod)))))
249+
(set-this-worker-in-pod!
250+
(->> (concat dirs jars) (into-array java.io.File) (boot.App/newPod))))))

0 commit comments

Comments
 (0)