I’ve a workflow that uses signal. When a client starts the workflow, it expects a result to be returned. The content of the results + more info added is used to send a signal back to the same workflow which then starts a childworkflow;
How do I return to the client the results of the highlighted activity i.e break out of the workflow?
Code below;
func workflow()(*somethingBackToClient, err) {
// activity A
// activity B
// activity C
// activity D <--- client is waiting on the result
var something * somethingBackToClient
workflow.ExecuteActivity().Get(ctx, & something)
s: = workflow.NewSelector(ctx)
codeSubmittedSignalName: = workflow.GetSignalChannel(ctx, CodeSubmittedSignalName)
s.AddReceive(codeSubmittedSignalName, func(c workflow.ReceiveChannel, more bool) {})
timerFuture: = workflow.NewTimer(childCtx, waitForCodeTimeout)
s.AddFuture(timerFuture, func(f workflow.Future) {})
s.Select(ctx)
if codeSubmittedSignalName.ReceiveAsync(&payload) {
// start child workflow with payload
} else {
// we never for a signal
// start revert activity C
cancelHandler() // cancel workflow
}
return &something
}