Skip to content

Commit

Permalink
IWF-119: Add handling ignoreAlreadyStartedError
Browse files Browse the repository at this point in the history
  • Loading branch information
lwolczynski committed Oct 29, 2024
1 parent 09262b0 commit 7e454e9
Showing 1 changed file with 9 additions and 3 deletions.
12 changes: 9 additions & 3 deletions service/api/service.go
Original file line number Diff line number Diff line change
Expand Up @@ -163,10 +163,17 @@ func (s *serviceImpl) ApiV1WorkflowStartPost(
shouldHandleError := true

if s.client.IsWorkflowAlreadyStartedError(err) && !ignoreAlreadyStartedError {
response, descErr := s.client.DescribeWorkflowExecution(ctx, req.GetWorkflowId(), "", nil)
if descErr != nil {
return nil, s.handleError(err, WorkflowStartApiPath, req.WorkflowId)
}

runId = response.RunId

if requestId == nil {
shouldHandleError = false
} else {
// TODO: compare the already started WorkflowAlreadyStartedRequestId with requestId
} else if response.Memos[service.WorkflowRequestId].Data == requestId {
shouldHandleError = false
}
}

Expand All @@ -178,7 +185,6 @@ func (s *serviceImpl) ApiV1WorkflowStartPost(
}

return &iwfidl.WorkflowStartResponse{
// TODO: if s.client.IsWorkflowAlreadyStartedError(err): set runId to the already started workflow
WorkflowRunId: iwfidl.PtrString(runId),
}, nil
}
Expand Down

0 comments on commit 7e454e9

Please sign in to comment.