File tree Expand file tree Collapse file tree
main/clojure/clojure/core/async
test/clojure/clojure/core/async Expand file tree Collapse file tree Original file line number Diff line number Diff line change 135135
136136(defn ping
137137 " pings all processes, returning a map of pid -> proc status and
138- state, for those procs that reply within timeout-ms (default 1000)"
138+ state, for those procs that reply within timeout-ms (default 1000).
139+ The value at ::flow/state is shaped by the proc's :ping-map-fn (see
140+ process), defaulting to the proc's raw state."
139141 [g & {:keys [timeout-ms] :or {timeout-ms 1000 }}]
140142 (g/ping g timeout-ms))
141143
186188 For the simple case of enumerated signal-ids, use a set,
187189 e.g. #{:this/signal :that/signal}
188190 If no :signal-select is provided, no signals will be received
191+ :ping-map-fn - (ping-map-fn state) -> ping-map. The ping-map is
192+ placed under ::flow/state in ping/ping-proc replies.
193+ Defaults to identity.
189194 :workload with possible values of :mixed :io :compute.
190195 All entries in the describe return map are optional.
191196
Original file line number Diff line number Diff line change 244244 " see lib ns for docs"
245245 [step {:keys [workload compute-timeout-ms] :or {compute-timeout-ms 5000 }}]
246246 (let [{:keys [params ins] :as desc} (step )
247- workload (or workload (:workload desc) :mixed )]
247+ workload (or workload (:workload desc) :mixed )
248+ ping-map-fn (or (:ping-map-fn desc) identity)]
248249 ; ;(assert (or (not params) init) "must have :init if :params")
249250 (reify
250251 clojure.core.protocols/Datafiable
276277 #::flow{:pid pid, :status status
277278 :count count
278279 :ins pins :outs pouts})
279- ::flow/state state))))
280+ ::flow/state ( ping-map-fn state) ))))
280281 handle-command (partial handle-command pid pong)
281282 [nstatus nstate count read-ins]
282283 (try
Original file line number Diff line number Diff line change 5353 (let [state-val {:a-var #'identity :a-fn inc}
5454 ping-state (ping-state-with (minimal-step state-val))]
5555 (is (= state-val ping-state) " state should be returned unchanged" ))))
56+
57+ (deftest test-ping-map-fn
58+ (testing " :ping-map-fn can redact sensitive keys from state"
59+ (let [ping-state (ping-state-with (minimal-step {:visible 42 :hidden " secret" }
60+ {:ping-map-fn #(select-keys % [:visible ])}))]
61+ (is (= {:visible 42 } ping-state) " secret was not removed" ))))
62+
You can’t perform that action at this time.
0 commit comments