Hello, I am new to Temporal and I am trying to implement with Temporal a workflow whose goal is to configure several services on behalf of a user.
The services are configured by both synchronous and async activities, depending on the service itself and, most importantly, some service configuration activity might require as input the output of a different service configuration.
Example: services A, B, C; given input “alpha” A requires B.out, C requires both A.out and B.out
To make it more complex, these dependencies are not “hard coded” because, depending on the input passed to the workflow, B might not require A.out and, in some cases there might even be a different, even opposite, dependency: given input “beta” B requires A.out, C requires both B.out and A.out
Given that it’s not really possible to code these dependencies in the workflow, my idea is to implement the workflow as a set of child workflows, one for each service A, B, C, …, all running in parallel with the same input.
If a service child workflow detects (inside an activity) that it misses some input, than it will fail in non recoverable way, otherwise will complete.
The parent workflow will gather the outputs of all succeeded child workflow and, in case of a child workflow failure, reschedule the failed workflow passing the consolidated output as the new input to it.
This approach should provide a sort of an “eventually consistent” workflow which execute several times the child workflows until they all succeed.
A slightly different solution could be this: the input of each child workflow is not passed as a parameter but is instead queried by the activity (or by the children workflow logic, before starting the activity) as a Query to the main workflow state, that acts as a global state which is set at the beginning of the workflow as “input” and mutated by the child workflows activities as a result of the configuration tasks (via Signal or directly mutating the state as a result of child workflows successful completion).
This second option seems more complex in terms of state handling, also I am afraid of not properly using the Temporal API and, most importantly, the overall approach to designing robust workflows.