I’m wondering whether this pattern is safe to use as a target for SignalWithStartWorkflow:
func (wf *MyWorkflow) ControlLoop(ctx workflow.Context, someID string) (err error) {
for {
evt := wf.pollLastEvent(ctx)
if evt == nil {
break // *** HERE
}
err = workflow.ExecuteChildWorkflow(
/* launch a handler workflow - the point of this is to serialise signal processing */
) // etc
}
// nothing left to do, so quit the workflow
return err
}
I think the issue here is that this control loop can poll and discover no signals pending (the // HERE
) and proceed to exit - as another signal arrives for processing. The workflow is “already running” so we see a warning: “Workflow has unhandled signals”
I’ve seen claims elsewhere that the above pattern is safe and that the workflow should be restarted; but I can’t find any solid documentation on this, and that doesn’t jibe with my observations. (The motivation for the above pattern was primarily to not have a bazillion idle workflows knocking around in a UI.)
Would appreciate a definitive answer “this is supposed to work” or “that is not guaranteed to work, don’t do it” so we can make some progress with this.