mirror of
https://github.com/hanzoai/tasks.git
synced 2026-11-03 03:56:04 +00:00
Full module path rebrand from Temporal to Hanzo Tasks: - go.mod module: github.com/hanzoai/tasks - All internal Go imports updated (1906 files) - cmd/server renamed to cmd/tasksd - Binary name: tasksd (was temporal-server) - Docker images: hanzoai/tasks (was temporalio/server) - README rewritten with Hanzo Tasks branding - LLM.md created with integration notes - Makefile, goreleaser, CI workflows updated - go.temporal.io/sdk and go.temporal.io/api imports preserved (separate repos) Fork of Temporal.io (MIT license).
52 lines
1.3 KiB
Go
52 lines
1.3 KiB
Go
package verifyfirstworkflowtaskscheduled
|
|
|
|
import (
|
|
"context"
|
|
|
|
enumsspb "github.com/hanzoai/tasks/api/enums/v1"
|
|
"github.com/hanzoai/tasks/api/historyservice/v1"
|
|
"github.com/hanzoai/tasks/common/definition"
|
|
"github.com/hanzoai/tasks/common/locks"
|
|
"github.com/hanzoai/tasks/common/namespace"
|
|
"github.com/hanzoai/tasks/service/history/api"
|
|
"github.com/hanzoai/tasks/service/history/consts"
|
|
)
|
|
|
|
func Invoke(
|
|
ctx context.Context,
|
|
req *historyservice.VerifyFirstWorkflowTaskScheduledRequest,
|
|
workflowConsistencyChecker api.WorkflowConsistencyChecker,
|
|
) (retError error) {
|
|
namespaceID := namespace.ID(req.GetNamespaceId())
|
|
if err := api.ValidateNamespaceUUID(namespaceID); err != nil {
|
|
return err
|
|
}
|
|
|
|
workflowLease, err := workflowConsistencyChecker.GetWorkflowLease(
|
|
ctx,
|
|
req.Clock,
|
|
definition.NewWorkflowKey(
|
|
req.NamespaceId,
|
|
req.WorkflowExecution.WorkflowId,
|
|
req.WorkflowExecution.RunId,
|
|
),
|
|
locks.PriorityLow,
|
|
)
|
|
if err != nil {
|
|
return err
|
|
}
|
|
defer func() { workflowLease.GetReleaseFn()(retError) }()
|
|
|
|
mutableState := workflowLease.GetMutableState()
|
|
if !mutableState.IsWorkflowExecutionRunning() &&
|
|
mutableState.GetExecutionState().State != enumsspb.WORKFLOW_EXECUTION_STATE_ZOMBIE {
|
|
return nil
|
|
}
|
|
|
|
if !mutableState.HadOrHasWorkflowTask() {
|
|
return consts.ErrWorkflowNotReady
|
|
}
|
|
|
|
return nil
|
|
}
|