Fork me on GitHub
#missionary
<
2023-08-29
>
Jakub08:08:56

When waiting for multiple tasks there is m/join and m/race which in terminology of JS Promises are like Promise.all and Promise.race respectively. Is there an equivalent to Promise.allSettled which would wait for all tasks to complete (either success or failure) and does not cancel other tasks when some task fails?

leonoel08:08:19

you can build it with attempt :

(defn all-settled [& tasks]
  (apply m/join vector (map m/attempt tasks)))
the task result will be a vector of zero-argument functions that you can call with try/catch to check status

Jakub08:08:04

cool, thank you šŸ‘

Dustin Getz13:08:31

Adding to my missionary-contrib namespace (currently embedded in Electric, will extract it at some point)

Dustin Getz13:08:49

Thinking about how Missionary can help with > https://www.juxt.pro/blog/clojure-in-griffin/#testing-for-correctness > Allen: So a thing Iā€™ve been banging around for a while, but havenā€™t really made any progress on yet is around testing of systems. ... two big problems that we have to deal with. One of them is race conditions, and the other is system errors. As a bank we have to be what is called ā€˜operationally resilientā€™, which really just means no downtime. > What the Foundation team did was build a simulator of the database. They have something like 20 different process types, so 20 different ā€˜rolesā€™ within the Foundation cluster, and they wrote them as single-threaded C++ apps. Then they built an actor-model concurrency compiler on top of C++. Every single system call or network call that they make goes through a protocol, so they can inject errors. All of their multi-threading also happens through this actor model with the sending of messages. > With all this in place, they can then say, ā€œOh, what happens if I send message A and then send message B, but then on the other end it arrives B and then A?ā€. Or ā€œWhat happens if, in the middle of processing this message, I try to write to disk and I get an error?ā€. They can inject errors anywhere in the system, deterministically. > You can think of it as kind of like test.check generative testing, where you have all non-determinism in the system seeded from a single random number that you control. You can control disk errors, network errors, and reordering of messages. Iā€™m really interested in having something like that. The problem right now is that thereā€™s no way to control the behavior of the underlying Java threading libraries, nio, and writing to disk.