Skip to content

Commit

Permalink
Clean up reset reapply default value (#2938)
Browse files Browse the repository at this point in the history
  • Loading branch information
alexshtin committed Jun 3, 2022
1 parent 4c11b96 commit c3d172d
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 21 deletions.
6 changes: 6 additions & 0 deletions common/enums/defaults.go
Original file line number Diff line number Diff line change
Expand Up @@ -63,3 +63,9 @@ func SetDefaultContinueAsNewInitiator(f *enumspb.ContinueAsNewInitiator) {
*f = enumspb.CONTINUE_AS_NEW_INITIATOR_WORKFLOW
}
}

func SetDefaultResetReapplyType(f *enumspb.ResetReapplyType) {
if *f == enumspb.RESET_REAPPLY_TYPE_UNSPECIFIED {
*f = enumspb.RESET_REAPPLY_TYPE_SIGNAL
}
}
12 changes: 3 additions & 9 deletions service/frontend/workflowHandler.go
Original file line number Diff line number Diff line change
Expand Up @@ -2154,15 +2154,9 @@ func (wh *WorkflowHandler) ResetWorkflowExecution(ctx context.Context, request *
return nil, err
}

switch request.GetResetReapplyType() {
case enumspb.RESET_REAPPLY_TYPE_UNSPECIFIED:
request.ResetReapplyType = enumspb.RESET_REAPPLY_TYPE_SIGNAL
case enumspb.RESET_REAPPLY_TYPE_SIGNAL:
// noop
case enumspb.RESET_REAPPLY_TYPE_NONE:
// noop
default:
return nil, serviceerror.NewInternal("unknown reset type")
enums.SetDefaultResetReapplyType(&request.ResetReapplyType)
if _, validType := enumspb.ResetReapplyType_name[int32(request.GetResetReapplyType())]; !validType {
return nil, serviceerror.NewInternal(fmt.Sprintf("unknown reset reapply type: %v", request.GetResetReapplyType()))
}

namespaceID, err := wh.namespaceRegistry.GetNamespaceID(namespace.Name(request.GetNamespace()))
Expand Down
11 changes: 0 additions & 11 deletions service/history/historyEngine.go
Original file line number Diff line number Diff line change
Expand Up @@ -2359,17 +2359,6 @@ func (e *historyEngineImpl) ResetWorkflowExecution(
return nil, serviceerror.NewInvalidArgument("Workflow task finish ID must be > 1 && <= workflow last event ID.")
}

switch request.GetResetReapplyType() {
case enumspb.RESET_REAPPLY_TYPE_UNSPECIFIED:
return nil, serviceerror.NewInvalidArgument("reset type not set")
case enumspb.RESET_REAPPLY_TYPE_SIGNAL:
// noop
case enumspb.RESET_REAPPLY_TYPE_NONE:
// noop
default:
return nil, serviceerror.NewInternal("unknown reset type")
}

// also load the current run of the workflow, it can be different from the base runID
currentRunID, err := e.workflowConsistencyChecker.GetCurrentRunID(
ctx,
Expand Down
2 changes: 1 addition & 1 deletion service/history/workflowResetter.go
Original file line number Diff line number Diff line change
Expand Up @@ -331,7 +331,7 @@ func (r *workflowResetterImpl) reapplyEventsToResetWorkflow(
case enumspb.RESET_REAPPLY_TYPE_NONE:
// noop
default:
panic(fmt.Sprintf("unknown reset type: %v", resetReapplyType))
panic(fmt.Sprintf("unknown reset reapply type: %v", resetReapplyType))
}

if err := r.reapplyEvents(resetMutableState, additionalReapplyEvents); err != nil {
Expand Down

0 comments on commit c3d172d

Please sign in to comment.