Files
fgueryandGitHub 03490da5a5 fix(EN-637): avoid uninstall timeout by using batching on deletion (#635)
* fix: refactor activity options declaration

* fix: increase uninstall storage activities' timeout across the board

* fix: make payments_delete_from_connector_id use batches + hearthbeat + higher temporal timeout

* fix: make instances, accounts and schedule use batche deletion too

* fix: refactored activity batch deletion, also batch event_sent deletion

* fix: forgot to change back the batch size after  manual testing

* fix: ensure batchsize >0
2026-01-16 13:28:09 +00:00

45 lines
1.2 KiB
Go

package workflow
import (
"time"
"github.com/formancehq/payments/internal/models"
"go.temporal.io/sdk/temporal"
"go.temporal.io/sdk/workflow"
)
func infiniteRetryContext(ctx workflow.Context) workflow.Context {
return infiniteRetryWithCustomStartToCloseAndHeartbeatContext(
ctx,
models.ActivityStartToCloseTimeoutMinutesDefault*time.Minute,
time.Duration(0),
)
}
func infiniteRetryWithLongTimeoutContext(ctx workflow.Context) workflow.Context {
return infiniteRetryWithCustomStartToCloseAndHeartbeatContext(
ctx,
models.ActivityStartToCloseTimeoutMinutesLong*time.Minute,
time.Duration(0),
)
}
func infiniteRetryWithCustomStartToCloseAndHeartbeatContext(ctx workflow.Context, startToCloseTimeout, heartbeatTimeout time.Duration) workflow.Context {
ao := workflow.ActivityOptions{
RetryPolicy: &temporal.RetryPolicy{
InitialInterval: time.Second,
BackoffCoefficient: 2,
MaximumInterval: 100 * time.Second,
NonRetryableErrorTypes: []string{},
},
}
if startToCloseTimeout != time.Duration(0) {
ao.StartToCloseTimeout = startToCloseTimeout
}
if heartbeatTimeout != time.Duration(0) {
ao.HeartbeatTimeout = heartbeatTimeout
}
return workflow.WithActivityOptions(ctx, ao)
}