manetu / temporal-clojure-sdk

A Temporal SDK for Clojure
Apache License 2.0
73 stars 10 forks source link

Add an `allSettled` promise handling function #56

Closed mintybayleaf closed 6 months ago

mintybayleaf commented 6 months ago

I added a new promise handling function called allSettled historically in most programming languages this function name waits for every promise to finish running (or failing) before performing operations on them.

I used this to wait for a batch of activities to run then handle the errors at the end if any exist.

I would like if I could implement here in the repository because leveraging the internals of the promise in the SDK here is a bit nasty to do in our repository.

This is a lot cleaner and could be useful to others.

I implemented the feature like this because of these two examples (as maxim suggested)

  1. https://github.com/temporalio/samples-java/tree/main/core/src/main/java/io/temporal/samples/batch

  2. https://community.temporal.io/t/async-activities-in-workflow/896

SIDE NOTE:

Also fixes a bug in the scheduling code that was not pulling the :schedule key out of the options passed into the schedule like one would assume.