missionary

J 2024-11-27T08:27:37.293209Z

Hi guys! Is this code valid? It works well but I have doubt about passing the memo as param function.

(defn ?task
  [opts]
  (m/sp
    (m/? (m/sleep 500))
    (let [?memo1 (get opts :?memo1)]
      (str "Res task: " (m/? ?memo1)))))

(defn ?other-task
  [opts]
  (m/sp
    (m/? (m/sleep 400))
    (let [?memo1 (get opts :?memo1)
          ?memo2 (get opts :?memo2)]
      (str "Res other-task: " (m/? ?memo1) ", " (m/? ?memo2)))))

(defn ?main
  []
  (let [?memo1 (m/memo (m/sp (m/? (m/sleep 600)) "OK"))
        ?memo2 (m/memo (?task {:?memo1 ?memo1}))]
    (m/join vector
            ?memo1
            ?memo2
            (?other-task {:?memo1 ?memo1 :?memo2 ?memo2}))))

(m/? (?main))

leonoel 2024-11-27T09:57:30.612009Z

yes, nothing wrong here

J 2024-11-27T09:59:16.191579Z

Thanks leo!

timur 2024-11-27T09:46:05.655369Z

Is missionary a good fit as a simple component lifecycle framework (think: Component/Mount/Integrant)? It supports cancellations, supervision trees, it is able to natively reacts to changes in configuration — it tempts me to try. Any hidden pitfalls?

2024-11-27T10:02:56.083669Z

@n.litened Thanks for your https://nextjournal.com/N-litened/missionary-for-dummies, I've been using missionary quite a bit but never did the in depth dives like you and it's helped me a ton. My live-reload situation in clojure nowadays is nearly the same as it is in clojurescript: saving a file reloads the affected namespaces. defonce + before-ns-unload of clj-reload makes my environment constantly up-to-date and hot-reload very fast. I think most lifecycle frameworks are way over the top and try to reinvent things that clojure does fine already. But perhaps I just never ran into the use-case of needing to be really flexible with my order of bringing systems up or down. My experience with all of them (except maybe mount) has been that it overcomplicates.

❤️ 1
timur 2024-11-27T11:06:00.810229Z

Yeah, I also tend to stick to simple Mount to manage state and reloads. However I’ve noticed that Missionary tends to “infect” all other parts of code of a project — so I’ve just wondered, maybe it makes sense to go with “missionary everywhere”? :) I wonder if anybody had gone that route and had opinion to share

2024-11-27T11:27:55.295629Z

Yeah, for me, so far so good on using missionary processes extensively.

🙏 1
2024-11-27T10:13:41.914159Z

And yeah, before-ns-unload in clojure often includes closing running missionary process, in clojurescript I (declare some-process) (when some-process (some-process)) to close it before restarting (during namespace load).