Thanks for pointing out the
Promise.anyOf working. I was actually meaning that we don’t care which Promise is returned from the list as long as we get the one thats completed. Because I can use the maps to run respective child interface activities accordingly.
About the other question.
The problem is that each “process” activity is complex and makes some API call and produces an output.
Technically, yes, we can rid of the BaseInterface needing a generic type. But that then makes us lose the ability to get and store an output from 1 activity and pass it onto some other activity for another class.
And if we have class level variables in these Activity classes for storing the output we then lose the ability to have a generic orchestration code than can take the output from one activity and call another activity with that output because now all classes have their own interface.
The example code and our requirement needs this generalization/base interface to avoid manually plugging in activity outputs and inputs (which means modifying the orchestrator every time a new class is added to this graph) when we have more than 30-40 of these classes.
Unless I am missing some other concept of Activities and Workflows I do not see how else I can have a some common orchestration code that can apply to a graph of activity classes.
For more context. The way I have solved this without Temporal is run each “process” method in a new thread and the orchestrator class would be able to pass outputs of some activity to another even if we lose type-safety. I was hoping to use Temporal as a backend in place of threads for these activities.