Skip to content

Commit 6d048aa

Browse files
authored
Merge pull request #21 from pfnet-research/add-processing-in-get-tasks
add 'processing' filter in get-task command
2 parents 926adbd + b3c2cb9 commit 6d048aa

File tree

4 files changed

+26
-1
lines changed

4 files changed

+26
-1
lines changed

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@
5757
- [Managing configurations](#managing-configurations)
5858
* [Command line flags](#command-line-flags)
5959
* [Eenvironment variables](#eenvironment-variables)
60-
* [Config files](#config-files)
60+
* [Config file](#config-file)
6161
- [Backend configuration reference](#backend-configuration-reference)
6262
* [Redis](#redis)
6363
- [Bash/Zsh completion](#bashzsh-completion)

cmd/get_task.go

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@ var (
3333
possibleTaskState = []string{
3434
"all",
3535
"pending",
36+
"processing",
3637
"completed",
3738
"succeeded",
3839
"failed",
@@ -71,6 +72,8 @@ var getTaskCmd = &cobra.Command{
7172
ts, err = queueBackend.GetAllTasks(cmdContext, queueName)
7273
case "pending":
7374
ts, err = queueBackend.GetPendingTasks(cmdContext, queueName)
75+
case "processing":
76+
ts, err = queueBackend.GetProcessingTasks(cmdContext, queueName)
7477
case "completed":
7578
ts, err = queueBackend.GetCompletedTasks(cmdContext, queueName)
7679
case "succeeded":

pkg/backend/iface/backend.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,7 @@ type Backend interface {
6161
AddTask(ctx context.Context, queueName string, spec task.TaskSpec) (*task.Task, error)
6262
NextTask(ctx context.Context, queueUID, workerUID uuid.UUID) (*task.Task, error)
6363
GetAllTasks(ctx context.Context, queueName string) ([]*task.Task, error)
64+
GetProcessingTasks(ctx context.Context, queueName string) ([]*task.Task, error)
6465
GetPendingTasks(ctx context.Context, queueName string) ([]*task.Task, error)
6566
GetReceivedTasks(ctx context.Context, queueName string) ([]*task.Task, error)
6667
GetCompletedTasks(ctx context.Context, queueName string) ([]*task.Task, error)

pkg/backend/redis/task.go

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -225,6 +225,27 @@ func (b *Backend) GetReceivedTasks(ctx context.Context, queueName string) ([]*ta
225225
)
226226
}
227227

228+
func (b *Backend) GetProcessingTasks(ctx context.Context, queueName string) ([]*task.Task, error) {
229+
if err := taskqueue.ValidateQueueName(queueName); err != nil {
230+
return nil, err
231+
}
232+
queue, err := b.ensureQueueExistsByName(b.Client, queueName)
233+
if err != nil {
234+
return nil, err
235+
}
236+
return b.getTasks(
237+
queue.UID.String(),
238+
func(t *task.Task) bool {
239+
return t.Status.Phase == task.TaskPhaseProcessing
240+
},
241+
b.Logger.With().
242+
Str("queueName", queue.Spec.Name).
243+
Str("queueUID", queue.UID.String()).
244+
Str("operation", "GetProcessingTasks").
245+
Logger(),
246+
)
247+
}
248+
228249
func (b *Backend) GetCompletedTasks(ctx context.Context, queueName string) ([]*task.Task, error) {
229250
if err := taskqueue.ValidateQueueName(queueName); err != nil {
230251
return nil, err

0 commit comments

Comments
 (0)