Hi,
I was wondering what the best approach would be for waiting for a number of external conditions, before executing a workflow. Specifically, some data independent data imports run, and I need to wait for all of them to complete. The data imports are also temporal workflows.
For example, the workflow main body is something like:
for runs < LifecycleMaxEvents || selector.HasPending() {
if monitor.firstRun {
// Here I want to wait for certain precondition are satisfied.
err := monitor.Check(ctx, time.Time{}, time.Time{}, monitor.firstRun)
if err != nil {
return err
}
monitor.firstRun = false
continue
}
tCtx, cancel := workflow.WithCancel(ctx)
timer := workflow.NewTimer(tCtx, time.Hour*24)
selector.AddFuture(timer, func(f workflow.Future) {
err = monitor.Check(ctx, time.Time{}, time.Time{}, false)
if err != nil {
cancel()
}
})
runs = runs + 1
selector.Select(ctx)
}
Can I for example, do external calls in a workflow.Await? Or this is not optimal?
Another option is I guess to signal this workflow from the external ones and set some local variables and await for those to be true?
Any suggestions, would be greatly appreciated.