mirror of
https://github.com/hanzoai/tasks.git
synced 2026-10-30 14:56:19 +00:00
## What changed? - Enforce archetype when loading mutable state ## Why? - Avoid workflow operation get applied to non-workflow archetypes. ## How did you test it? - [x] built - [ ] run locally and tested manually - [x] covered by existing tests - [ ] added new unit test(s) - [ ] added new functional test(s)
39 lines
944 B
Go
39 lines
944 B
Go
package refreshworkflow
|
|
|
|
import (
|
|
"context"
|
|
|
|
"go.temporal.io/server/chasm"
|
|
"go.temporal.io/server/common/definition"
|
|
"go.temporal.io/server/common/locks"
|
|
"go.temporal.io/server/common/namespace"
|
|
"go.temporal.io/server/service/history/api"
|
|
historyi "go.temporal.io/server/service/history/interfaces"
|
|
)
|
|
|
|
func Invoke(
|
|
ctx context.Context,
|
|
workflowKey definition.WorkflowKey,
|
|
shardContext historyi.ShardContext,
|
|
workflowConsistencyChecker api.WorkflowConsistencyChecker,
|
|
) (retError error) {
|
|
err := api.ValidateNamespaceUUID(namespace.ID(workflowKey.NamespaceID))
|
|
if err != nil {
|
|
return err
|
|
}
|
|
|
|
chasmLease, err := workflowConsistencyChecker.GetChasmLease(
|
|
ctx,
|
|
nil,
|
|
workflowKey,
|
|
chasm.ArchetypeAny, // RefreshWorkflow works for all Archetypes.
|
|
locks.PriorityLow,
|
|
)
|
|
if err != nil {
|
|
return err
|
|
}
|
|
defer func() { chasmLease.GetReleaseFn()(retError) }()
|
|
|
|
return chasmLease.GetContext().RefreshTasks(ctx, shardContext)
|
|
}
|