go.uber.org/cadence@v1.2.9/test/replaytests/continue_as_new_wf.go (about) 1 package replaytests 2 3 import ( 4 "go.uber.org/cadence/workflow" 5 "go.uber.org/zap" 6 ) 7 8 // ContinueAsNewWorkflow is a sample Cadence workflows that can receive a signal 9 func ContinueAsNewWorkflow(ctx workflow.Context) error { 10 selector := workflow.NewSelector(ctx) 11 var signalResult string 12 signalName := "helloWorldSignal" 13 for { 14 signalChan := workflow.GetSignalChannel(ctx, signalName) 15 selector.AddReceive(signalChan, func(c workflow.Channel, more bool) { 16 c.Receive(ctx, &signalResult) 17 workflow.GetLogger(ctx).Info("Received age signalResult from signal!", zap.String("signal", signalName), zap.String("value", signalResult)) 18 }) 19 workflow.GetLogger(ctx).Info("Waiting for signal on channel.. " + signalName) 20 // Wait for signal 21 selector.Select(ctx) 22 if signalResult == "kill" { 23 return nil 24 } 25 } 26 }