Skip to content

Add Channel.ReceiveWithTimeout #789

@mfateev

Description

@mfateev

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)

Metadata

Metadata

Assignees

No one assigned

    Labels

    featurenew feature request

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions