add new all-settled promise handler #57
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
This is really good for
batching
activities in a workflow or maybe one child workflows in a workflowI used this to wait for a batch of activities to run then handle the errors at the end if any exist.
I would like it if I could implement the function in the repository because leveraging the internals of the temporal.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 (at least I think so)
I implemented the feature like this because of these two examples from the Temporal core team (as maxim suggested)
https://github.com/temporalio/samples-java/tree/main/core/src/main/java/io/temporal/samples/batch
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.