Files
tasks/service/history/api/getdlqtasks/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

66 lines
2.0 KiB
Go

// Package getdlqtasks contains the logic to implement the [historyservice.HistoryServiceServer.GetDLQTasks] API.
package getdlqtasks
import (
"context"
"errors"
"go.temporal.io/api/serviceerror"
commonspb "github.com/hanzoai/tasks/api/common/v1"
"github.com/hanzoai/tasks/api/historyservice/v1"
"github.com/hanzoai/tasks/common/persistence"
"github.com/hanzoai/tasks/service/history/api"
"github.com/hanzoai/tasks/service/history/consts"
"github.com/hanzoai/tasks/service/history/tasks"
)
// Invoke the GetDLQTasks API. All errors returned from this function are already translated into the appropriate type
// from the [serviceerror] package.
func Invoke(
ctx context.Context,
historyTaskQueueManager persistence.HistoryTaskQueueManager,
taskCategoryRegistry tasks.TaskCategoryRegistry,
req *historyservice.GetDLQTasksRequest,
) (*historyservice.GetDLQTasksResponse, error) {
category, err := api.GetTaskCategory(int(req.DlqKey.TaskCategory), taskCategoryRegistry)
if err != nil {
return nil, err
}
response, err := historyTaskQueueManager.ReadRawTasks(ctx, &persistence.ReadTasksRequest{
QueueKey: persistence.QueueKey{
QueueType: persistence.QueueTypeHistoryDLQ,
Category: category,
SourceCluster: req.DlqKey.SourceCluster,
TargetCluster: req.DlqKey.TargetCluster,
},
PageSize: int(req.PageSize),
NextPageToken: req.NextPageToken,
})
if err != nil {
if errors.Is(err, persistence.ErrReadTasksNonPositivePageSize) {
return nil, consts.ErrInvalidPageSize
}
return nil, serviceerror.NewUnavailablef("GetDLQTasks failed. Error: %v", err)
}
dlqTasks := make([]*commonspb.HistoryDLQTask, len(response.Tasks))
for i, task := range response.Tasks {
dlqTasks[i] = &commonspb.HistoryDLQTask{
Metadata: &commonspb.HistoryDLQTaskMetadata{
MessageId: task.MessageMetadata.ID,
},
Payload: &commonspb.HistoryTask{
ShardId: task.Payload.ShardId,
Blob: task.Payload.Blob,
},
}
}
return &historyservice.GetDLQTasksResponse{
DlqTasks: dlqTasks,
NextPageToken: response.NextPageToken,
}, nil
}