mirror of
https://github.com/hanzoai/tasks.git
synced 2026-10-04 02:04:03 +00:00
## What changed? - Use force deletion for chasm execution in namespace deletion - Add functional test for forcing deleting chasm executions - We have log for force deletion as well ## Why? - DeleteWorkflowExecution API is an async graceful deletion api that only works for Workflow, but not other CHASM archetypes. - Upon namespace deletion we need to delete chasm executions as well and we can use force deletion to do it. ## How did you test it? - [x] built - [ ] run locally and tested manually - [ ] covered by existing tests - [x] added new unit test(s) - [x] added new functional test(s)
43 lines
1.1 KiB
Go
43 lines
1.1 KiB
Go
package common
|
|
|
|
import (
|
|
"fmt"
|
|
"strconv"
|
|
"unicode"
|
|
|
|
workflowpb "go.temporal.io/api/workflow/v1"
|
|
"go.temporal.io/server/chasm"
|
|
"go.temporal.io/server/common/payload"
|
|
"go.temporal.io/server/common/searchattribute/sadefs"
|
|
)
|
|
|
|
func ArchetypeIDFromExecutionInfo(
|
|
executionInfo *workflowpb.WorkflowExecutionInfo,
|
|
) (chasm.ArchetypeID, error) {
|
|
indexedField := executionInfo.SearchAttributes.GetIndexedFields()
|
|
if indexedField == nil {
|
|
return chasm.WorkflowArchetypeID, nil
|
|
}
|
|
|
|
nsDivisionPayload, ok := indexedField[sadefs.TemporalNamespaceDivision]
|
|
if !ok {
|
|
return chasm.WorkflowArchetypeID, nil
|
|
}
|
|
|
|
var nsDivisionStr string
|
|
if err := payload.Decode(nsDivisionPayload, &nsDivisionStr); err != nil {
|
|
return chasm.UnspecifiedArchetypeID, fmt.Errorf("failed to decode TemporalNamespaceDivision field: %w", err)
|
|
}
|
|
|
|
if len(nsDivisionStr) == 0 || !unicode.IsDigit(rune(nsDivisionStr[0])) {
|
|
return chasm.WorkflowArchetypeID, nil
|
|
}
|
|
|
|
archetypeID, err := strconv.ParseUint(nsDivisionStr, 10, 32)
|
|
if err != nil {
|
|
return chasm.UnspecifiedArchetypeID, fmt.Errorf("failed to parse archetypeID: %w", err)
|
|
}
|
|
|
|
return chasm.ArchetypeID(archetypeID), nil
|
|
}
|