Skip to content

Commit

Permalink
fix: update delete task job and list tasks job api args.
Browse files Browse the repository at this point in the history
Signed-off-by: Asklv <[email protected]>
  • Loading branch information
IRONICBo committed Aug 4, 2024
1 parent dcbb0f7 commit 16cb224
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 17 deletions.
20 changes: 8 additions & 12 deletions internal/job/types.go
Original file line number Diff line number Diff line change
Expand Up @@ -35,33 +35,29 @@ type PreheatResponse struct {

// ListTasksRequest defines the request parameters for listing tasks.
type ListTasksRequest struct {
TaskID string `json:"task_id" validate:"required"`
Page int `json:"page" validate:"required"`
PerPage int `json:"per_page" validate:"required"`
TaskID string `json:"task_id" validate:"required"`
}

// ListTasksResponse defines the response parameters for listing tasks.
type ListTasksResponse struct {
Peers []*resource.Peer `json:"peers"`
Page int `json:"page"`
Total int `json:"total"`
}

// DeleteTaskRequest defines the request parameters for deleting task.
type DeleteTaskRequest struct {
TaskID string `json:"task_id" validate:"required"`
}

// TaskInfo includes information about a task along with peer details and a description.
type TaskInfo struct {
Task *resource.Task `json:"task"`
Peer *resource.Peer `json:"peer"`
Desc string `json:"desc"`
// Task includes information about a task along with peer details and a description.
type Task struct {
Task *resource.Task `json:"task"`
Peer *resource.Peer `json:"peer"`
Description string `json:"description"`
}

// DeleteTaskResponse represents the response after attempting to delete tasks,
// categorizing them into successfully and unsuccessfully deleted.
type DeleteTaskResponse struct {
SuccessTasks []*TaskInfo `json:"success_tasks"`
FailureTasks []*TaskInfo `json:"failure_tasks"`
SuccessTasks []*Task `json:"success_tasks"`
FailureTasks []*Task `json:"failure_tasks"`
}
2 changes: 0 additions & 2 deletions manager/job/manager_tasks.go
Original file line number Diff line number Diff line change
Expand Up @@ -79,8 +79,6 @@ func (m *managerTasks) CreateListTasks(ctx context.Context, schedulers []models.
var span trace.Span
ctx, span = tracer.Start(ctx, config.SpanListTasks, trace.WithSpanKind(trace.SpanKindProducer))
span.SetAttributes(config.AttributeListTasksID.String(json.TaskID))
span.SetAttributes(config.AttributeListTasksPage.Int(json.Page))
span.SetAttributes(config.AttributeListTasksPerPage.Int(json.PerPage))
defer span.End()

args, err := internaljob.MarshalRequest(json)
Expand Down
4 changes: 1 addition & 3 deletions manager/types/job.go
Original file line number Diff line number Diff line change
Expand Up @@ -80,9 +80,7 @@ type CreateListTasksJobRequest struct {
}

type ListTasksArgs struct {
TaskID string `json:"task_id" binding:"required"`
Page int `json:"page" binding:"omitempty,gte=1"`
PerPage int `json:"per_page" binding:"omitempty,gte=1,lte=10000000"`
TaskID string `json:"task_id" binding:"required"`
}

type PreheatArgs struct {
Expand Down

0 comments on commit 16cb224

Please sign in to comment.