Fork me on GitHub
#juxt
<
2020-05-29
>
onetom08:05:33

@dominicm it seems the juxt.clip.core/stop calls the component's stop function twice. is that intended? im cleaning up dbs from my stop functions and they are not idempotent, so they fail on the 2nd run.

(def cfg {:components
            {:wheel {:start {:part "wheel"}
                     :stop  prn}}})
  (def sys (clip/start cfg))
  (clip/stop cfg sys)

=> #'repl/cfg
=> #'repl/sys
{:part "wheel"}
{:part "wheel"}
=> {:wheel nil}
and the implementation indeed seems to simply repeat the stop operation:
(defn stopping-f
  [[k {:keys [stop]}]]
  (fn [rf acc]
    (stop! (get acc k) stop)
    (-> acc
        (rf k (stop! (get acc k) stop)))))
https://github.com/juxt/clip/blob/26cb6c926b42c8b8886149d5c65c6d6568ad1cc8/src/juxt/clip/impl/core.cljc#L337-L342

onetom08:05:16

it seems to me that stopping-f is a reducer, but it only implements a 2-arity version, but the 1st (stop! (get acc k) stop) was intended for a single arity version or something...?

dominicm09:05:38

I've done something stupid it seems. I'll take a look this weekend.

👍 4
❤️ 4