@@ -73,6 +73,11 @@ type (
7373 // ParentClosePolicy defines the behavior performed on a child workflow when its parent is closed
7474 ParentClosePolicy = internal.ParentClosePolicy
7575
76+ // CancelOption values are functional options for the CancelWorkflow method.
77+ // Supported values can be created with:
78+ // - WithCancelReason(...)
79+ CancelOption = internal.Option
80+
7681 // Client is the client for starting and getting information about a workflow executions as well as
7782 // completing activities asynchronously.
7883 Client interface {
@@ -162,7 +167,7 @@ type (
162167 // - BadRequestError
163168 // - InternalServiceError
164169 // - WorkflowExecutionAlreadyCompletedError
165- CancelWorkflow (ctx context.Context , workflowID string , runID string , opts ... internal. Option ) error
170+ CancelWorkflow (ctx context.Context , workflowID string , runID string , opts ... CancelOption ) error
166171
167172 // TerminateWorkflow terminates a workflow execution.
168173 // workflowID is required, other parameters are optional.
@@ -516,3 +521,10 @@ func IsWorkflowError(err error) bool {
516521 }
517522 return false
518523}
524+
525+ // WithCancelReason can be passed to Client.CancelWorkflow to provide an explicit cancellation reason,
526+ // which will be recorded in the cancellation event in the workflow's history, similar to termination reasons.
527+ // This is purely informational, and does not influence Cadence behavior at all.
528+ func WithCancelReason (reason string ) CancelOption {
529+ return internal .WithCancelReason (reason )
530+ }
0 commit comments