reason string,
requestID string,
opTag := tag.WorkflowActionWorkflowPaused
if err := ms.checkMutability(opTag); err != nil {
return nil, err
}
event := ms.hBuilder.AddWorkflowExecutionPausedEvent(identity, reason, requestID)
mutable_state_impl.go
if err := ms.ApplyWorkflowExecutionPausedEvent(event); err != nil {
return nil, err
}
}
// ApplyWorkflowExecutionPausedEvent applies the paused event to the mutable state. It updates the workflow execution status to paused and sets the pause info.
func (ms *MutableStateImpl) ApplyWorkflowExecutionPausedEvent(event *historypb.HistoryEvent) error {
mutable_state_impl.go
// Update workflow status.
if _, err := ms.UpdateWorkflowStateStatus(ms.executionState.GetState(), enumspb.WORKFLOW_EXECUTION_STATUS_PAUSED); err != nil {
return err
}
// Set pause info in mutable state.
PauseTime: timestamppb.New(event.GetEventTime().AsTime()),
Identity: event.GetWorkflowExecutionPausedEventAttributes().GetIdentity(),
Reason: event.GetWorkflowExecutionPausedEventAttributes().GetReason(),
RequestId: event.GetWorkflowExecutionPausedEventAttributes().GetRequestId(),
}
// Update approximate size of the mutable state. This will be decreased when the pause info is removed (when the workflow is unpaused)
ms.approximateSize += ms.executionInfo.PauseInfo.Size()
// Invalidate all the pending activities. Do not mark individual activities as paused.
for _, ai := range ms.GetPendingActivityInfos() {
if err := ms.UpdateActivity(ai.ScheduledEventId, func(activityInfo *persistencespb.ActivityInfo, _ historyi.MutableState) error {
activityInfo.Stamp = activityInfo.Stamp + 1