I have a process that I have created a workflow for:
The progress of this process is driven by a third party and we will be receiving webhooks for the various states. We also perform activities before and after this process is initialted with the third party.
My question is whether it’s better to create multiple signal channels, one for each state(webhook). And making use of selectors:
for {
selector := workflow.NewSelector(ctx)
selector.AddReceive(channelForWebhook1, func(c workflow.ReceiveChannel, _ bool) {
var signal interface{}
c.Receive(ctx, &signal)
// Handle signal for webhook 1
})
selector.AddReceive(channelForWebhook2, func(c workflow.ReceiveChannel, _ bool) {
var signal interface{}
c.Receive(ctx, &signal)
// Handle signal for webhook 2
})
// Other signal channels per webhook required for this workflow.
selector.Select(ctx)
}
Or to use a single signal per workflow. And handle the logic of differentiating the state(webhook) types in the workflow itself.
Are there any benefits to either implementation that we should be aware of? Or is this just an implementation detail?