mirror of
https://github.com/hanzoai/tasks.git
synced 2026-11-03 03:56:04 +00:00
## What changed? - Always marshal migration execution info using businessID to be compatible with the logic in cloud. - Unmarshaling part still accepts both workflowID and businessID so that people can upgrade from OSS v1.30. - Depends on https://github.com/temporalio/temporal/pull/9085 - This change will be part of OSS v1.31 but not v1.30. ## Why? - Fix breaking changes for cloud ## How did you test it? - [ ] built - [ ] run locally and tested manually - [ ] covered by existing tests - [x] added new unit test(s) - [ ] added new functional test(s)
37 lines
916 B
Go
37 lines
916 B
Go
package migration
|
|
|
|
import (
|
|
"encoding/json"
|
|
)
|
|
|
|
type ExecutionInfo struct {
|
|
BusinessID string `json:"business_id,omitempty"`
|
|
RunID string `json:"run_id,omitempty"`
|
|
ArchetypeID uint32 `json:"archetype_id,omitempty"`
|
|
}
|
|
|
|
type executionInfoLegacyJSON struct {
|
|
BusinessID string `json:"business_id,omitempty"`
|
|
WorkflowID string `json:"workflow_id,omitempty"`
|
|
RunID string `json:"run_id,omitempty"`
|
|
ArchetypeID uint32 `json:"archetype_id,omitempty"`
|
|
}
|
|
|
|
func (e *ExecutionInfo) UnmarshalJSON(data []byte) error {
|
|
// For backward compatibility, support both workflow_id and business_id here.
|
|
var legacy executionInfoLegacyJSON
|
|
if err := json.Unmarshal(data, &legacy); err != nil {
|
|
return err
|
|
}
|
|
|
|
businessID := legacy.WorkflowID
|
|
if legacy.BusinessID != "" {
|
|
businessID = legacy.BusinessID
|
|
}
|
|
|
|
e.BusinessID = businessID
|
|
e.RunID = legacy.RunID
|
|
e.ArchetypeID = legacy.ArchetypeID
|
|
return nil
|
|
}
|