Skip to content

Commit

Permalink
Bug in retry testing
Browse files Browse the repository at this point in the history
  • Loading branch information
jakobht committed Dec 3, 2024
1 parent df6f7bd commit 6a898f8
Showing 1 changed file with 17 additions and 0 deletions.
17 changes: 17 additions & 0 deletions cmd/samples/recipes/helloworld/helloworld_workflow.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package main

import (
"context"
"fmt"
"time"

"go.uber.org/cadence/activity"
Expand All @@ -20,10 +21,20 @@ const helloWorldWorkflowName = "helloWorldWorkflow"

// helloWorkflow workflow decider
func helloWorldWorkflow(ctx workflow.Context, name string) error {
retry := workflow.RetryPolicy{
InitialInterval: time.Second,
BackoffCoefficient: 0,
MaximumInterval: 0,
ExpirationInterval: 0,
MaximumAttempts: 1,
NonRetriableErrorReasons: nil,
}

ao := workflow.ActivityOptions{
ScheduleToStartTimeout: time.Minute,
StartToCloseTimeout: time.Minute,
HeartbeatTimeout: time.Second * 20,
RetryPolicy: &retry,
}
ctx = workflow.WithActivityOptions(ctx, ao)

Expand Down Expand Up @@ -58,6 +69,12 @@ func helloWorldWorkflow(ctx workflow.Context, name string) error {
}

func helloWorldActivity(ctx context.Context, name string) (string, error) {
fmt.Printf("Hello %s!\n", name)
fmt.Printf("Attempt %v!\n", activity.GetInfo(ctx).Attempt)
if activity.GetInfo(ctx).Attempt == 0 {
return "", fmt.Errorf("retryable error")
}

logger := activity.GetLogger(ctx)
logger.Info("helloworld activity started")
return "Hello " + name + "!", nil
Expand Down

0 comments on commit 6a898f8

Please sign in to comment.