You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Is your feature request related to a problem? Please describe.
Currently to guarantee that every signal is delivered all channels have to be drained using ReadAsync before completing a workflow. This leads to code that looks like:
typechannelConfigstruct {
channel workflow.ReceiveChannelvalinterface{}
handlerfunc() // do something with val
}
channels:= []*channelConfig{
{
channel: workflow.GetSignalChannel(...)
val: "",
handlerfunc() {
// do something with val
},
},
// etc
}
s:=workflow.NewSelector(ctx)
for_, cc:=rangechannels {
s.AddReceive(cc.channel, func (c workflow.ReceiveChannel, _bool) {
c.Receive(ctx, &cc.val)
cc.handler()
})
}
forkeepGoing {
s.Select(ctx)
// not safe to return here
}
// Now I want to return but first I need to make sure that no signals are pendingcanReturn:=falsefor!canReturn {
canReturn=truefor_, cc:=rangechannels {
ifok:=c.ReceiveAsync(&cc.val); ok {
canReturn=falsecc.handler()
}
}
}
Describe the solution you'd like
Add Selector.HasPending method that returns true if Selector.Select is not going to block if called. This would simplify the above code to:
typechannelConfigstruct {
channel workflow.ReceiveChannelvalinterface{}
handlerfunc() // do something with val
}
channels:= []*channelConfig{
{
channel: workflow.GetSignalChannel(...)
val: "",
handlerfunc() {
// do something with val
},
},
// etc
}
s:=workflow.NewSelector(ctx)
for_, cc:=rangechannels {
s.AddReceive(cc.channel, func (c workflow.ReceiveChannel, _bool) {
c.Receive(ctx, &cc.val)
cc.handler()
})
}
forkeepGoing||s.HasPending {
s.Select(ctx)
}
// safe complete workflow here
Describe alternatives you've considered
Add Channel.HasPending or ReceiveChannel.Peek. But it wouldn't help with Select and still require code complications.
Is your feature request related to a problem? Please describe.
Currently to guarantee that every signal is delivered all channels have to be drained using ReadAsync before completing a workflow. This leads to code that looks like:
Describe the solution you'd like
Add Selector.HasPending method that returns true if Selector.Select is not going to block if called. This would simplify the above code to:
Describe alternatives you've considered
Add Channel.HasPending or ReceiveChannel.Peek. But it wouldn't help with Select and still require code complications.
Additional context
https://community.temporal.io/t/continueasnew-signals/1008/25
The text was updated successfully, but these errors were encountered: