How to set a Start-To-Close Timeout in Go
To set a Start-To-Close Timeout, create an instance of ActivityOptions
from the go.temporal.io/sdk/workflow
package, set the StartToCloseTimeout
field, and then use the WithActivityOptions()
API to apply the options to the instance of workflow.Context
.
This or ScheduleToClose
must be set.
- Type:
time.Duration
- Default: Same as the
ScheduleToCloseTimeout
activityoptions := workflow.ActivityOptions{
StartToCloseTimeout: 10 * time.Second,
}
ctx = workflow.WithActivityOptions(ctx, activityoptions)
var yourActivityResult YourActivityResult
err = workflow.ExecuteActivity(ctx, YourActivityDefinition, yourActivityParam).Get(ctx, &yourActivityResult)
if err != nil {
// ...
}