Go StartWorkflowOptions reference
Create an instance of StartWorkflowOptions from the go.temporal.io/sdk/client package, and pass the instance to the ExecuteWorkflow call.
The following fields are available:
| Field | Required | Type |
|---|---|---|
ID | No | string |
TaskQueue | Yes | string |
WorkflowExecutionTimeout | No | time.Duration |
WorkflowRunTimeout | No | time.Duration |
WorkflowTaskTimeout | No | time.Duration |
WorkflowIDReusePolicy | No | WorkflowIdReusePolicy |
WorkflowExecutionErrorWhenAlreadyStarted | No | bool |
RetryPolicy | No | RetryPolicy |
CronSchedule | No | string |
Memo | No | map[string]interface{} |
SearchAttributes | No | map[string]interface{} |
ID
Create an instance of StartWorkflowOptions from the go.temporal.io/sdk/client package, set the ID field, and pass the instance to the ExecuteWorkflow call.
- Type:
string - Default: System generated UUID
workflowOptions := client.StartWorkflowOptions{
// ...
ID: "Your-Custom-Workflow-Id",
// ...
}
workflowRun, err := c.ExecuteWorkflow(context.Background(), workflowOptions, YourWorkflowDefinition)
if err != nil {
// ...
}
TaskQueue
Create an instance of StartWorkflowOptions from the go.temporal.io/sdk/client package, set the TaskQueue field, and pass the instance to the ExecuteWorkflow call.
- Type:
string - Default: None, this is a required field to be set by the developer
workflowOptions := client.StartWorkflowOptions{
// ...
TaskQueue: "your-task-queue",
// ...
}
workflowRun, err := c.ExecuteWorkflow(context.Background(), workflowOptions, YourWorkflowDefinition)
if err != nil {
// ...
}
WorkflowExecutionTimeout
Create an instance of StartWorkflowOptions from the go.temporal.io/sdk/client package, set the WorkflowExecutionTimeout field, and pass the instance to the ExecuteWorkflow call.
- Type:
time.Duration - Default: Unlimited
workflowOptions := client.StartWorkflowOptions{
// ...
WorkflowExecutionTimeout: time.Hours * 24 * 365 * 10,
// ...
}
workflowRun, err := c.ExecuteWorkflow(context.Background(), workflowOptions, YourWorkflowDefinition)
if err != nil {
// ...
}
WorkflowRunTimeout
Create an instance of StartWorkflowOptions from the go.temporal.io/sdk/client package, set the WorkflowRunTimeout field, and pass the instance to the ExecuteWorkflow call.
- Type:
time.Duration - Default: Same as
WorkflowExecutionTimeout
workflowOptions := client.StartWorkflowOptions{
WorkflowRunTimeout: time.Hours * 24 * 365 * 10,
// ...
}
workflowRun, err := c.ExecuteWorkflow(context.Background(), workflowOptions, YourWorkflowDefinition)
if err != nil {
// ...
}
WorkflowTaskTimeout
Create an instance of StartWorkflowOptions from the go.temporal.io/sdk/client package, set the WorkflowTaskTimeout field, and pass the instance to the ExecuteWorkflow call.
- Type:
time.Duration - Default:
time.Seconds * 10
workflowOptions := client.StartWorkflowOptions{
WorkflowTaskTimeout: time.Second * 10,
//...
}
workflowRun, err := c.ExecuteWorkflow(context.Background(), workflowOptions, YourWorkflowDefinition)
if err != nil {
// ...
}
WorkflowIDReusePolicy
- Type:
WorkflowIdReusePolicy - Default:
enums.WORKFLOW_ID_REUSE_POLICY_ALLOW_DUPLICATE
Set a value from the go.temporal.io/api/enums/v1 package.
workflowOptions := client.StartWorkflowOptions{
WorkflowIdReusePolicy: enums.WORKFLOW_ID_REUSE_POLICY_ALLOW_DUPLICATE,
// ...
}
workflowRun, err := c.ExecuteWorkflow(context.Background(), workflowOptions, YourWorkflowDefinition)
if err != nil {
// ...
}
WorkflowExecutionErrorWhenAlreadyStarted
- Type:
bool - Default:
false
workflowOptions := client.StartWorkflowOptions{
WorkflowExecutionErrorWhenAlreadyStarted: false,
// ...
}
workflowRun, err := c.ExecuteWorkflow(context.Background(), workflowOptions, YourWorkflowDefinition)
if err != nil {
// ...
}
RetryPolicy
Create an instance of a RetryPolicy from the go.temporal.io/sdk/temporal package and provide it as the value to the RetryPolicy field of the instance of StartWorkflowOptions.
- Type:
RetryPolicy - Default: None
retrypolicy := &temporal.RetryPolicy{
InitialInterval: time.Second,
BackoffCoefficient: 2.0,
MaximumInterval: time.Second * 100,
}
workflowOptions := client.StartWorkflowOptions{
RetryPolicy: retrypolicy,
// ...
}
workflowRun, err := temporalClient.ExecuteWorkflow(context.Background(), workflowOptions, YourWorkflowDefinition)
if err != nil {
// ...
}
CronSchedule
- Type:
string - Default: None
workflowOptions := client.StartWorkflowOptions{
CronSchedule: "15 8 * * *",
// ...
}
workflowRun, err := c.ExecuteWorkflow(context.Background(), workflowOptions, YourWorkflowDefinition)
if err != nil {
// ...
}
Memo
- Type:
map[string]interface{} - Default: Empty
workflowOptions := client.StartWorkflowOptions{
Memo: map[string]interface{}{
"description": "Test search attributes workflow",
},
// ...
}
workflowRun, err := c.ExecuteWorkflow(context.Background(), workflowOptions, YourWorkflowDefinition)
if err != nil {
// ...
}
SearchAttributes
How to set Workflow Execution Search Attributes in Go
- Type:
map[string]interface{} - Default: Empty.
These are the corresponding Search Attribute value types in Go:
- Keyword = string
- Int = int64
- Double = float64
- Bool = bool
- Datetime = time.Time
- Text = string
searchAttributes := map[string]interface{}{
"CustomIntField": 1,
"MiscData": "yellow",
}
workflowOptions := client.StartWorkflowOptions{
SearchAttributes: searchAttributes,
// ...
}
workflowRun, err := c.ExecuteWorkflow(context.Background(), workflowOptions, YourWorkflowDefinition)
if err != nil {
// ...
}