Files
tasks/service/history/api/resetactivity/api.go
zeekay 5a601d081b rebrand: go.temporal.io/server -> github.com/hanzoai/tasks
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).
2026-03-19 10:36:40 -07:00

77 lines
2.1 KiB
Go

package resetactivity
import (
"context"
"go.temporal.io/api/workflowservice/v1"
"github.com/hanzoai/tasks/api/historyservice/v1"
"github.com/hanzoai/tasks/common/definition"
"github.com/hanzoai/tasks/service/history/api"
"github.com/hanzoai/tasks/service/history/consts"
historyi "github.com/hanzoai/tasks/service/history/interfaces"
"github.com/hanzoai/tasks/service/history/workflow"
)
func Invoke(
ctx context.Context,
req *historyservice.ResetActivityRequest,
shardContext historyi.ShardContext,
workflowConsistencyChecker api.WorkflowConsistencyChecker,
) (resp *historyservice.ResetActivityResponse, retError error) {
request := req.GetFrontendRequest()
workflowKey := definition.NewWorkflowKey(
req.NamespaceId,
request.GetExecution().GetWorkflowId(),
request.GetExecution().GetRunId(),
)
err := api.GetAndUpdateWorkflowWithNew(
ctx,
nil,
workflowKey,
func(workflowLease api.WorkflowLease) (*api.UpdateWorkflowAction, error) {
mutableState := workflowLease.GetMutableState()
var activityIDs []string
switch a := request.GetActivity().(type) {
case *workflowservice.ResetActivityRequest_Id:
activityIDs = append(activityIDs, a.Id)
case *workflowservice.ResetActivityRequest_Type:
activityType := a.Type
for _, ai := range mutableState.GetPendingActivityInfos() {
if ai.ActivityType.Name == activityType {
activityIDs = append(activityIDs, ai.ActivityId)
}
}
}
if len(activityIDs) == 0 {
return nil, consts.ErrActivityNotFound
}
for _, activityId := range activityIDs {
if err := workflow.ResetActivity(
ctx,
shardContext, mutableState, activityId,
request.ResetHeartbeat, request.KeepPaused, request.RestoreOriginalOptions,
request.Jitter.AsDuration(),
); err != nil {
return nil, err
}
}
return &api.UpdateWorkflowAction{
Noop: false,
CreateWorkflowTask: false,
}, nil
},
nil,
shardContext,
workflowConsistencyChecker,
)
if err != nil {
return nil, err
}
return &historyservice.ResetActivityResponse{}, nil
}