Skip to content

Commit

Permalink
forgot updateworkflowbyid
Browse files Browse the repository at this point in the history
  • Loading branch information
yuandrew committed Nov 15, 2024
1 parent d49647c commit 330189d
Showing 1 changed file with 9 additions and 0 deletions.
9 changes: 9 additions & 0 deletions internal/internal_workflow_testsuite.go
Original file line number Diff line number Diff line change
Expand Up @@ -2962,17 +2962,26 @@ func (env *testWorkflowEnvironmentImpl) updateWorkflowByID(workflowID, name, id
panic(err)
}

if env.updateMap == nil {
env.updateMap = make(map[string]updateResult)
}

var ucWrapper = updateCallbacksWrapper{uc: uc, env: env, updateID: id}

// Check for duplicate update ID
if result, ok := env.updateMap[id]; ok {
result.mu.Lock()
workflowHandle.env.postCallback(func() {
ucWrapper.uc.Accept()
ucWrapper.uc.Complete(result.success, result.err)
defer result.mu.Unlock()
}, false)
} else {
env.updateMap[id] = updateResult{nil, nil, &sync.Mutex{}}
env.updateMap[id].mu.Lock()
workflowHandle.env.postCallback(func() {
workflowHandle.env.updateHandler(name, id, data, nil, ucWrapper)
defer env.updateMap[id].mu.Unlock()
}, true)
}

Expand Down

0 comments on commit 330189d

Please sign in to comment.