@@ -2,6 +2,7 @@ package main
22
33import (
44 "context"
5+ "fmt"
56 "time"
67
78 "go.uber.org/cadence/activity"
@@ -20,10 +21,20 @@ const helloWorldWorkflowName = "helloWorldWorkflow"
2021
2122// helloWorkflow workflow decider
2223func helloWorldWorkflow (ctx workflow.Context , name string ) error {
24+ retry := workflow.RetryPolicy {
25+ InitialInterval : time .Second ,
26+ BackoffCoefficient : 0 ,
27+ MaximumInterval : 0 ,
28+ ExpirationInterval : 0 ,
29+ MaximumAttempts : 1 ,
30+ NonRetriableErrorReasons : nil ,
31+ }
32+
2333 ao := workflow.ActivityOptions {
2434 ScheduleToStartTimeout : time .Minute ,
2535 StartToCloseTimeout : time .Minute ,
2636 HeartbeatTimeout : time .Second * 20 ,
37+ RetryPolicy : & retry ,
2738 }
2839 ctx = workflow .WithActivityOptions (ctx , ao )
2940
@@ -58,6 +69,12 @@ func helloWorldWorkflow(ctx workflow.Context, name string) error {
5869}
5970
6071func helloWorldActivity (ctx context.Context , name string ) (string , error ) {
72+ fmt .Printf ("Hello %s!\n " , name )
73+ fmt .Printf ("Attempt %v!\n " , activity .GetInfo (ctx ).Attempt )
74+ if activity .GetInfo (ctx ).Attempt == 0 {
75+ return "" , fmt .Errorf ("retryable error" )
76+ }
77+
6178 logger := activity .GetLogger (ctx )
6279 logger .Info ("helloworld activity started" )
6380 return "Hello " + name + "!" , nil
0 commit comments