Skip to content

Commit

Permalink
add throttling when there is a syncErr
Browse files Browse the repository at this point in the history
  • Loading branch information
iskakaushik committed Dec 13, 2024
1 parent 0a8fa90 commit 01985b9
Showing 1 changed file with 10 additions and 1 deletion.
11 changes: 10 additions & 1 deletion flow/workflows/sync_flow.go
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ func SyncFlowWorkflow(
}

syncFlowCtx := workflow.WithActivityOptions(syncSessionCtx, workflow.ActivityOptions{
StartToCloseTimeout: 72 * time.Hour,
StartToCloseTimeout: 7 * 24 * time.Hour,
HeartbeatTimeout: time.Minute,
WaitForCancellation: true,
})
Expand Down Expand Up @@ -162,6 +162,15 @@ func SyncFlowWorkflow(
}

restart := syncErr || workflow.GetInfo(ctx).GetContinueAsNewSuggested()

if syncErr {
logger.Info("sync flow error, sleeping for 30 seconds...")
err := workflow.Sleep(ctx, 30*time.Second)
if err != nil {
logger.Error("failed to sleep", slog.Any("error", err))
}
}

if !stop && !syncErr && mustWait {
waitSelector.Select(ctx)
if restart {
Expand Down

0 comments on commit 01985b9

Please sign in to comment.