Skip to content

Commit 1f21413

Browse files
committed
Return useful exception when attempting to start monitor with unstarted flow.
1 parent da18c30 commit 1f21413

1 file changed

Lines changed: 6 additions & 5 deletions

File tree

src/clojure/core/async/flow_monitor.clj

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
(ns clojure.core.async.flow-monitor
22
(:require
33
[clojure.core.async :as async]
4-
[clojure.core.async.flow :as flow]
4+
[clojure.core.async.flow :as async-flow]
55
[ring.util.response :as response]
66
[ring.middleware.content-type :refer [wrap-content-type]]
77
[ring.middleware.not-modified :refer [wrap-not-modified]]
@@ -72,7 +72,7 @@
7272
(assoc k (mainline-chan-meta v))
7373
(assoc k (filter-state v (:filters @state)))))
7474
{}
75-
(flow/ping (:flow @state))))})
75+
(async-flow/ping (:flow @state))))})
7676
(Thread/sleep 1000)
7777
(recur s))
7878
(println "Ping loop stopped")))))
@@ -90,9 +90,9 @@
9090
(let [clj-data (transit-str-reader data)
9191
action (:action clj-data)]
9292
(case action
93-
:inject (flow/inject (:flow @state) (:target clj-data) (edn/read-string (:data clj-data)))
94-
:resume-proc (flow/resume-proc (:flow @state) (:pid clj-data))
95-
:pause-proc (flow/pause-proc (:flow @state) (:pid clj-data)))))
93+
:inject (async-flow/inject (:flow @state) (:target clj-data) (edn/read-string (:data clj-data)))
94+
:resume-proc (async-flow/resume-proc (:flow @state) (:pid clj-data))
95+
:pause-proc (async-flow/pause-proc (:flow @state) (:pid clj-data)))))
9696
:on-close (fn [ch status]
9797
(swap! state assoc-in [:loop-ping?] false)
9898
(swap! state update-in [:channels] disj ch))
@@ -145,6 +145,7 @@
145145
(let [state (atom default-state)
146146
error-chan (:clojure.datafy/obj (meta (:error (:chans (d/datafy flow)))))
147147
report-chan (:clojure.datafy/obj (meta (:report (:chans (d/datafy flow)))))]
148+
(async-flow/ping flow)
148149
(swap! state assoc :flow flow :handlers handlers :filters filters :root root)
149150
(report-monitoring state report-chan error-chan)
150151
(let [server (httpkit/run-server (app state) {:port port

0 commit comments

Comments
 (0)