Skip to main content

Overview

Workflow types define the core structures for workflow execution in Cadence. These types are used across all services to represent workflow state, decisions, and execution metadata. Source Location: common/types/shared.go

Workflow Execution Types

WorkflowExecution

Uniquely identifies a workflow execution instance.
type WorkflowExecution struct {
    WorkflowID string
    RunID      string
}
WorkflowID
string
required
Business identifier for the workflow. Must be unique per domain according to the WorkflowIdReusePolicy.
RunID
string
Unique identifier for this specific run of the workflow. Generated by Cadence when the workflow starts.
Example:
{
  "workflowId": "order-12345",
  "runId": "a3e8c7f1-4b2a-4c5d-8e9f-1a2b3c4d5e6f"
}

WorkflowType

Identifies the workflow implementation type.
type WorkflowType struct {
    Name string
}
Name
string
required
Name of the workflow type, must match the registered workflow implementation.
Example:
{
  "name": "OrderProcessingWorkflow"
}

WorkflowExecutionInfo

Contains comprehensive information about a workflow execution.
type WorkflowExecutionInfo struct {
    Execution            *WorkflowExecution
    Type                 *WorkflowType
    StartTime            *int64
    CloseTime            *int64
    CloseStatus          *WorkflowExecutionCloseStatus
    HistoryLength        int64
    ParentDomainID       *string
    ParentExecution      *WorkflowExecution
    ExecutionTime        *int64
    Memo                 *Memo
    SearchAttributes     *SearchAttributes
    AutoResetPoints      *ResetPoints
    TaskList             string
    IsCron               bool
    UpdateTime           *int64
    PartitionConfig      map[string]string
}
Execution
WorkflowExecution
Workflow execution identifier
Type
WorkflowType
Workflow type
StartTime
int64
Unix timestamp (nanoseconds) when workflow started
CloseTime
int64
Unix timestamp (nanoseconds) when workflow closed
CloseStatus
WorkflowExecutionCloseStatus
Final status if workflow is closed (Completed, Failed, Canceled, Terminated, ContinuedAsNew, TimedOut)
HistoryLength
int64
Total number of events in workflow history
ParentDomainID
string
Domain UUID of parent workflow if this is a child workflow
ParentExecution
WorkflowExecution
Parent workflow execution if this is a child workflow
ExecutionTime
int64
Actual execution start time (may differ from StartTime for cron workflows)
Memo
Memo
Non-indexed workflow metadata
SearchAttributes
SearchAttributes
Indexed attributes for advanced visibility queries
AutoResetPoints
ResetPoints
Auto-generated reset points in workflow history
TaskList
string
Task list name for decision tasks
IsCron
boolean
Whether this is a cron workflow

WorkflowExecutionConfiguration

Configuration settings for a workflow execution.
type WorkflowExecutionConfiguration struct {
    TaskList                            *TaskList
    ExecutionStartToCloseTimeoutSeconds *int32
    TaskStartToCloseTimeoutSeconds      *int32
}
TaskList
TaskList
Task list for decision tasks
ExecutionStartToCloseTimeoutSeconds
int32
Maximum workflow execution duration in seconds
TaskStartToCloseTimeoutSeconds
int32
Maximum decision task duration in seconds

Workflow Close Status

WorkflowExecutionCloseStatus

Enumeration of possible workflow completion states.
type WorkflowExecutionCloseStatus int32

const (
    WorkflowExecutionCloseStatusCompleted WorkflowExecutionCloseStatus = iota
    WorkflowExecutionCloseStatusFailed
    WorkflowExecutionCloseStatusCanceled
    WorkflowExecutionCloseStatusTerminated
    WorkflowExecutionCloseStatusContinuedAsNew
    WorkflowExecutionCloseStatusTimedOut
)
Completed
int32
default:"0"
Workflow completed successfully
Failed
int32
default:"1"
Workflow failed with an error
Canceled
int32
default:"2"
Workflow was canceled
Terminated
int32
default:"3"
Workflow was forcefully terminated
ContinuedAsNew
int32
default:"4"
Workflow continued as a new execution
TimedOut
int32
default:"5"
Workflow execution timed out

Decision Types

Decision

Represents a decision made by the workflow during decision task processing.
type Decision struct {
    DecisionType                                             *DecisionType
    ScheduleActivityTaskDecisionAttributes                   *ScheduleActivityTaskDecisionAttributes
    StartTimerDecisionAttributes                             *StartTimerDecisionAttributes
    CompleteWorkflowExecutionDecisionAttributes              *CompleteWorkflowExecutionDecisionAttributes
    FailWorkflowExecutionDecisionAttributes                  *FailWorkflowExecutionDecisionAttributes
    RequestCancelActivityTaskDecisionAttributes              *RequestCancelActivityTaskDecisionAttributes
    CancelTimerDecisionAttributes                            *CancelTimerDecisionAttributes
    CancelWorkflowExecutionDecisionAttributes                *CancelWorkflowExecutionDecisionAttributes
    RequestCancelExternalWorkflowExecutionDecisionAttributes *RequestCancelExternalWorkflowExecutionDecisionAttributes
    RecordMarkerDecisionAttributes                           *RecordMarkerDecisionAttributes
    ContinueAsNewWorkflowExecutionDecisionAttributes         *ContinueAsNewWorkflowExecutionDecisionAttributes
    StartChildWorkflowExecutionDecisionAttributes            *StartChildWorkflowExecutionDecisionAttributes
    SignalExternalWorkflowExecutionDecisionAttributes        *SignalExternalWorkflowExecutionDecisionAttributes
    UpsertWorkflowSearchAttributesDecisionAttributes         *UpsertWorkflowSearchAttributesDecisionAttributes
}

DecisionType

Enumeration of decision types.
type DecisionType int32

const (
    DecisionTypeScheduleActivityTask DecisionType = iota
    DecisionTypeRequestCancelActivityTask
    DecisionTypeStartTimer
    DecisionTypeCancelTimer
    DecisionTypeCompleteWorkflowExecution
    DecisionTypeFailWorkflowExecution
    DecisionTypeCancelWorkflowExecution
    DecisionTypeRequestCancelExternalWorkflowExecution
    DecisionTypeRecordMarker
    DecisionTypeContinueAsNewWorkflowExecution
    DecisionTypeStartChildWorkflowExecution
    DecisionTypeSignalExternalWorkflowExecution
    DecisionTypeUpsertWorkflowSearchAttributes
)

Activity Types

ActivityType

Identifies an activity implementation.
type ActivityType struct {
    Name string
}
Name
string
required
Name of the activity type, must match the registered activity implementation.

ScheduleActivityTaskDecisionAttributes

Attributes for scheduling an activity task.
type ScheduleActivityTaskDecisionAttributes struct {
    ActivityID                    string
    ActivityType                  *ActivityType
    Domain                        *string
    TaskList                      *TaskList
    Input                         []byte
    ScheduleToCloseTimeoutSeconds *int32
    ScheduleToStartTimeoutSeconds *int32
    StartToCloseTimeoutSeconds    *int32
    HeartbeatTimeoutSeconds       *int32
    RetryPolicy                   *RetryPolicy
    Header                        *Header
    RequestLocalDispatch          *bool
}
ActivityID
string
required
Unique identifier for this activity within the workflow
ActivityType
ActivityType
required
Type of activity to execute
Domain
string
Domain for cross-domain activities (defaults to workflow domain)
TaskList
TaskList
required
Task list to dispatch the activity to
Input
[]byte
Serialized activity input
ScheduleToCloseTimeoutSeconds
int32
Maximum time from schedule to completion
ScheduleToStartTimeoutSeconds
int32
Maximum time from schedule until activity starts
StartToCloseTimeoutSeconds
int32
Maximum time from start to completion
HeartbeatTimeoutSeconds
int32
Maximum time between heartbeats
RetryPolicy
RetryPolicy
Retry policy for automatic retries
Header
Header
Context propagation headers
RequestLocalDispatch
boolean
Request activity execution on same worker as decision task

Workflow Completion Types

CompleteWorkflowExecutionDecisionAttributes

Complete a workflow successfully.
type CompleteWorkflowExecutionDecisionAttributes struct {
    Result []byte
}
Result
[]byte
Serialized workflow result

FailWorkflowExecutionDecisionAttributes

Fail a workflow with an error.
type FailWorkflowExecutionDecisionAttributes struct {
    Reason  *string
    Details []byte
}
Reason
string
Error reason/message
Details
[]byte
Serialized error details

CancelWorkflowExecutionDecisionAttributes

Cancel a workflow.
type CancelWorkflowExecutionDecisionAttributes struct {
    Details []byte
}
Details
[]byte
Serialized cancellation details

ContinueAsNewWorkflowExecutionDecisionAttributes

Continue the workflow as a new execution.
type ContinueAsNewWorkflowExecutionDecisionAttributes struct {
    WorkflowType                        *WorkflowType
    TaskList                            *TaskList
    Input                               []byte
    ExecutionStartToCloseTimeoutSeconds *int32
    TaskStartToCloseTimeoutSeconds      *int32
    BackoffStartIntervalInSeconds       *int32
    RetryPolicy                         *RetryPolicy
    Initiator                           *ContinueAsNewInitiator
    FailureReason                       *string
    FailureDetails                      []byte
    LastCompletionResult                []byte
    CronSchedule                        string
    Header                              *Header
    Memo                                *Memo
    SearchAttributes                    *SearchAttributes
}
WorkflowType
WorkflowType
Workflow type for new execution (defaults to current type)
TaskList
TaskList
Task list for new execution (defaults to current)
Input
[]byte
Input for new execution
ExecutionStartToCloseTimeoutSeconds
int32
Execution timeout for new run
TaskStartToCloseTimeoutSeconds
int32
Decision task timeout for new run
BackoffStartIntervalInSeconds
int32
Delay before starting new execution
Initiator
ContinueAsNewInitiator
What triggered continue-as-new (Decider, RetryPolicy, CronSchedule)
LastCompletionResult
[]byte
Result from current execution
CronSchedule
string
Cron schedule for new execution

Timer Types

StartTimerDecisionAttributes

Start a durable timer.
type StartTimerDecisionAttributes struct {
    TimerID                   string
    StartToFireTimeoutSeconds *int64
}
TimerID
string
required
Unique identifier for this timer
StartToFireTimeoutSeconds
int64
required
Duration until timer fires (in seconds)

CancelTimerDecisionAttributes

Cancel a pending timer.
type CancelTimerDecisionAttributes struct {
    TimerID string
}
TimerID
string
required
ID of the timer to cancel

Child Workflow Types

StartChildWorkflowExecutionDecisionAttributes

Start a child workflow execution.
type StartChildWorkflowExecutionDecisionAttributes struct {
    Domain                              string
    WorkflowID                          string
    WorkflowType                        *WorkflowType
    TaskList                            *TaskList
    Input                               []byte
    ExecutionStartToCloseTimeoutSeconds *int32
    TaskStartToCloseTimeoutSeconds      *int32
    ParentClosePolicy                   *ParentClosePolicy
    Control                             []byte
    WorkflowIDReusePolicy               *WorkflowIDReusePolicy
    RetryPolicy                         *RetryPolicy
    CronSchedule                        string
    Header                              *Header
    Memo                                *Memo
    SearchAttributes                    *SearchAttributes
}
Domain
string
Domain for child workflow (defaults to parent domain)
WorkflowID
string
required
Workflow ID for child execution
WorkflowType
WorkflowType
required
Child workflow type
ParentClosePolicy
ParentClosePolicy
What to do with child when parent closes (Abandon, RequestCancel, Terminate)
Control
[]byte
Opaque control data passed to child

Marker Types

RecordMarkerDecisionAttributes

Record a marker event in workflow history.
type RecordMarkerDecisionAttributes struct {
    MarkerName string
    Details    []byte
    Header     *Header
}
MarkerName
string
required
Name of the marker
Details
[]byte
Serialized marker details
Header
Header
Context headers
Use Cases:
  • Side effects tracking
  • Local activities
  • Workflow versioning markers
  • Custom instrumentation

External Workflow Types

SignalExternalWorkflowExecutionDecisionAttributes

Send a signal to another workflow.
type SignalExternalWorkflowExecutionDecisionAttributes struct {
    Domain            string
    Execution         *WorkflowExecution
    SignalName        string
    Input             []byte
    Control           []byte
    ChildWorkflowOnly bool
}
Domain
string
required
Domain of target workflow
Execution
WorkflowExecution
required
Target workflow execution (RunID optional)
SignalName
string
required
Name of signal to send
Input
[]byte
Serialized signal payload
ChildWorkflowOnly
boolean
Only signal if target is a child workflow

RequestCancelExternalWorkflowExecutionDecisionAttributes

Request cancellation of another workflow.
type RequestCancelExternalWorkflowExecutionDecisionAttributes struct {
    Domain            string
    WorkflowID        string
    RunID             string
    Control           []byte
    ChildWorkflowOnly bool
}
Domain
string
required
Domain of target workflow
WorkflowID
string
required
Workflow ID to cancel
RunID
string
Specific run ID to cancel (optional)
ChildWorkflowOnly
boolean
Only cancel if target is a child workflow

Search Attributes

UpsertWorkflowSearchAttributesDecisionAttributes

Update workflow search attributes.
type UpsertWorkflowSearchAttributesDecisionAttributes struct {
    SearchAttributes *SearchAttributes
}
SearchAttributes
SearchAttributes
required
New or updated search attributes

SearchAttributes

Indexed attributes for advanced visibility.
type SearchAttributes struct {
    IndexedFields map[string][]byte
}
IndexedFields
map[string][]byte
required
Map of attribute names to serialized values. Supported types: String, Int, Double, Bool, Datetime, Keyword.
Example:
{
  "indexedFields": {
    "CustomerId": "\"customer-12345\"",
    "OrderAmount": "99.99",
    "OrderDate": "\"2024-01-15T10:30:00Z\"",
    "IsPriority": "true"
  }
}

Retry Policy

RetryPolicy

Defines automatic retry behavior.
type RetryPolicy struct {
    InitialIntervalInSeconds    int32
    BackoffCoefficient          float64
    MaximumIntervalInSeconds    int32
    MaximumAttempts             int32
    NonRetriableErrorReasons    []string
    ExpirationIntervalInSeconds int32
}
InitialIntervalInSeconds
int32
required
Initial retry delay
BackoffCoefficient
float64
required
Backoff multiplier (must be >= 1.0)
MaximumIntervalInSeconds
int32
Maximum retry delay cap
MaximumAttempts
int32
Maximum retry attempts (0 = unlimited)
NonRetriableErrorReasons
[]string
Error reasons that should not trigger retry
ExpirationIntervalInSeconds
int32
Total retry window duration
Example:
{
  "initialIntervalInSeconds": 1,
  "backoffCoefficient": 2.0,
  "maximumIntervalInSeconds": 60,
  "maximumAttempts": 5,
  "nonRetriableErrorReasons": ["InvalidInput", "Unauthorized"]
}

Memo

Memo

Non-indexed workflow metadata.
type Memo struct {
    Fields map[string][]byte
}
Fields
map[string][]byte
Map of field names to serialized values. Not indexed, but can be retrieved.
Use Cases:
  • Large metadata that doesn’t need indexing
  • Binary data
  • Structured context information

Header

Context propagation headers.
type Header struct {
    Fields map[string][]byte
}
Fields
map[string][]byte
Map of header names to serialized values. Propagated to activities and child workflows.
Use Cases:
  • Tracing context (trace ID, span ID)
  • Authentication tokens
  • Request metadata
  • Feature flags

Pending Execution Info

PendingActivityInfo

Information about a pending activity.
type PendingActivityInfo struct {
    ActivityID             string
    ActivityType           *ActivityType
    State                  *PendingActivityState
    HeartbeatDetails       []byte
    LastHeartbeatTimestamp *int64
    LastStartedTimestamp   *int64
    Attempt                int32
    MaximumAttempts        int32
    ScheduledTimestamp     *int64
    ExpirationTimestamp    *int64
    LastFailureReason      *string
    LastWorkerIdentity     string
    LastFailureDetails     []byte
}

PendingChildExecutionInfo

Information about a pending child workflow.
type PendingChildExecutionInfo struct {
    WorkflowID        string
    RunID             string
    WorkflowTypeName  string
    InitiatedID       int64
    ParentClosePolicy *ParentClosePolicy
}

PendingDecisionInfo

Information about a pending decision task.
type PendingDecisionInfo struct {
    State                      *PendingDecisionState
    ScheduledTimestamp         *int64
    StartedTimestamp           *int64
    Attempt                    int64
    OriginalScheduledTimestamp *int64
}

Reset Points

ResetPoints

Auto-generated reset points for workflow reset.
type ResetPoints struct {
    Points []*ResetPointInfo
}

ResetPointInfo

Information about a single reset point.
type ResetPointInfo struct {
    BinaryChecksum           string
    RunID                    string
    FirstDecisionCompletedID int64
    CreatedTimeNano          *int64
    ExpiringTimeNano         *int64
    Resettable               bool
}
BinaryChecksum
string
Checksum of worker binary at this point
FirstDecisionCompletedID
int64
Event ID of first decision task completion
Resettable
boolean
Whether workflow can be reset to this point

Workflow ID Reuse Policy

WorkflowIDReusePolicy

Policy for reusing workflow IDs.
type WorkflowIDReusePolicy int32

const (
    WorkflowIDReusePolicyAllowDuplicateFailedOnly WorkflowIDReusePolicy = iota
    WorkflowIDReusePolicyAllowDuplicate
    WorkflowIDReusePolicyRejectDuplicate
    WorkflowIDReusePolicyTerminateIfRunning
)
AllowDuplicateFailedOnly
int32
default:"0"
Allow starting if previous execution failed, canceled, or terminated
AllowDuplicate
int32
default:"1"
Allow starting regardless of previous execution status
RejectDuplicate
int32
default:"2"
Reject if any previous execution exists
TerminateIfRunning
int32
default:"3"
Terminate existing execution and start new one

Parent Close Policy

ParentClosePolicy

Policy for child workflow when parent closes.
type ParentClosePolicy int32

const (
    ParentClosePolicyAbandon ParentClosePolicy = iota
    ParentClosePolicyRequestCancel
    ParentClosePolicyTerminate
)
Abandon
int32
default:"0"
Leave child workflow running
RequestCancel
int32
default:"1"
Request cancellation of child workflow
Terminate
int32
default:"2"
Forcefully terminate child workflow

See Also

Build docs developers (and LLMs) love