Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add Channel.ReceiveWithTimeout #789

Open
mfateev opened this issue Jul 13, 2019 · 1 comment
Open

Add Channel.ReceiveWithTimeout #789

mfateev opened this issue Jul 13, 2019 · 1 comment

Comments

@mfateev
Copy link
Contributor

mfateev commented Jul 13, 2019

Add convinience method

ReceiveWithTimeout(ctx Context, timeout time.Duration, valuePtr interface{}) (timedOut, more bool)

This would make this frequently used code:

sigCh := workflow.GetSignalChannel(ctx, "signal1")
timeout := workflow.NewTimer(ctx, time.Minute * 30)
var signal *SignalStruct

s := workflow.NewSelector(ctx)
s.AddFuture(timeout, func(f Future) {
})
s.AddReceive(sigCh, func(c Channel, more bool) {
    c.Receive(ctx, signal)
})
s.Select(ctx)

into

sigCh := workflow.GetSignalChannel(ctx, "signal1")
var signal *SignalStruct
sigCh.ReceiveWithTimeout(ctx, time.Minute * 30, signal)
@enuoCM
Copy link
Contributor

enuoCM commented Jun 7, 2020

Hi, How about the Channel.Receive, it will be canceled automatically after the workflow timeout?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants