From 8830d2338897686db1e4224c2782d30742136f86 Mon Sep 17 00:00:00 2001 From: Ken Hibino Date: Mon, 9 Dec 2019 19:33:07 -0800 Subject: [PATCH] Rename rdb methods to enqueue scheduled, retry, and dead tasks --- internal/rdb/inspect.go | 12 ++++++------ internal/rdb/inspect_test.go | 24 ++++++++++++------------ tools/asynqmon/cmd/enq.go | 6 +++--- 3 files changed, 21 insertions(+), 21 deletions(-) diff --git a/internal/rdb/inspect.go b/internal/rdb/inspect.go index 294effe..5c83dc1 100644 --- a/internal/rdb/inspect.go +++ b/internal/rdb/inspect.go @@ -230,10 +230,10 @@ func (r *RDB) ListDead() ([]*DeadTask, error) { return tasks, nil } -// Rescue finds a task that matches the given id and score from dead queue +// EnqueueDeadTask finds a task that matches the given id and score from dead queue // and enqueues it for processing. If a task that matches the id and score // does not exist, it returns ErrTaskNotFound. -func (r *RDB) Rescue(id string, score float64) error { +func (r *RDB) EnqueueDeadTask(id string, score float64) error { n, err := r.removeAndEnqueue(deadQ, id, score) if err != nil { return err @@ -244,10 +244,10 @@ func (r *RDB) Rescue(id string, score float64) error { return nil } -// RetryNow finds a task that matches the given id and score from retry queue +// EnqueueRetryTask finds a task that matches the given id and score from retry queue // and enqueues it for processing. If a task that matches the id and score // does not exist, it returns ErrTaskNotFound. -func (r *RDB) RetryNow(id string, score float64) error { +func (r *RDB) EnqueueRetryTask(id string, score float64) error { n, err := r.removeAndEnqueue(retryQ, id, score) if err != nil { return err @@ -258,10 +258,10 @@ func (r *RDB) RetryNow(id string, score float64) error { return nil } -// ProcessNow finds a task that matches the given id and score from scheduled queue +// EnqueueScheduledTask finds a task that matches the given id and score from scheduled queue // and enqueues it for processing. If a task that matches the id and score does not // exist, it returns ErrTaskNotFound. -func (r *RDB) ProcessNow(id string, score float64) error { +func (r *RDB) EnqueueScheduledTask(id string, score float64) error { n, err := r.removeAndEnqueue(scheduledQ, id, score) if err != nil { return err diff --git a/internal/rdb/inspect_test.go b/internal/rdb/inspect_test.go index 9cf367a..2b8f7f7 100644 --- a/internal/rdb/inspect_test.go +++ b/internal/rdb/inspect_test.go @@ -471,7 +471,7 @@ func TestListDead(t *testing.T) { var timeCmpOpt = EquateApproxTime(time.Second) -func TestRescue(t *testing.T) { +func TestEnqueueDeadTask(t *testing.T) { r := setup(t) t1 := randomTask("send_email", "default", nil) @@ -486,7 +486,7 @@ func TestRescue(t *testing.T) { dead []deadEntry score float64 id string - want error // expected return value from calling Rescue + want error // expected return value from calling EnqueueDeadTask wantDead []*TaskMessage wantEnqueued []*TaskMessage }{ @@ -527,9 +527,9 @@ func TestRescue(t *testing.T) { } } - got := r.Rescue(tc.id, tc.score) + got := r.EnqueueDeadTask(tc.id, tc.score) if got != tc.want { - t.Errorf("r.Rescue(%s, %0.f) = %v, want %v", tc.id, tc.score, got, tc.want) + t.Errorf("r.EnqueueDeadTask(%s, %0.f) = %v, want %v", tc.id, tc.score, got, tc.want) continue } @@ -547,7 +547,7 @@ func TestRescue(t *testing.T) { } } -func TestRetryNow(t *testing.T) { +func TestEnqueueRetryTask(t *testing.T) { r := setup(t) t1 := randomTask("send_email", "default", nil) @@ -562,7 +562,7 @@ func TestRetryNow(t *testing.T) { dead []retryEntry score float64 id string - want error // expected return value from calling RetryNow + want error // expected return value from calling EnqueueRetryTask wantRetry []*TaskMessage wantEnqueued []*TaskMessage }{ @@ -603,9 +603,9 @@ func TestRetryNow(t *testing.T) { } } - got := r.RetryNow(tc.id, tc.score) + got := r.EnqueueRetryTask(tc.id, tc.score) if got != tc.want { - t.Errorf("r.RetryNow(%s, %0.f) = %v, want %v", tc.id, tc.score, got, tc.want) + t.Errorf("r.EnqueueRetryTask(%s, %0.f) = %v, want %v", tc.id, tc.score, got, tc.want) continue } @@ -623,7 +623,7 @@ func TestRetryNow(t *testing.T) { } } -func TestProcessNow(t *testing.T) { +func TestEnqueueScheduledTask(t *testing.T) { r := setup(t) t1 := randomTask("send_email", "default", nil) @@ -638,7 +638,7 @@ func TestProcessNow(t *testing.T) { dead []scheduledEntry score float64 id string - want error // expected return value from calling ProcessNow + want error // expected return value from calling EnqueueScheduledTask wantScheduled []*TaskMessage wantEnqueued []*TaskMessage }{ @@ -679,9 +679,9 @@ func TestProcessNow(t *testing.T) { } } - got := r.ProcessNow(tc.id, tc.score) + got := r.EnqueueScheduledTask(tc.id, tc.score) if got != tc.want { - t.Errorf("r.RetryNow(%s, %0.f) = %v, want %v", tc.id, tc.score, got, tc.want) + t.Errorf("r.EnqueueRetryTask(%s, %0.f) = %v, want %v", tc.id, tc.score, got, tc.want) continue } diff --git a/tools/asynqmon/cmd/enq.go b/tools/asynqmon/cmd/enq.go index f164990..b11de39 100644 --- a/tools/asynqmon/cmd/enq.go +++ b/tools/asynqmon/cmd/enq.go @@ -53,11 +53,11 @@ func enq(cmd *cobra.Command, args []string) { })) switch qtype { case "s": - err = r.ProcessNow(id.String(), float64(score)) + err = r.EnqueueScheduledTask(id.String(), float64(score)) case "r": - err = r.RetryNow(id.String(), float64(score)) + err = r.EnqueueRetryTask(id.String(), float64(score)) case "d": - err = r.Rescue(id.String(), float64(score)) + err = r.EnqueueDeadTask(id.String(), float64(score)) default: fmt.Println("invalid argument") os.Exit(1)