mirror of
https://github.com/hibiken/asynq.git
synced 2024-12-25 07:12:17 +08:00
Rename rdb methods to enqueue scheduled, retry, and dead tasks
This commit is contained in:
parent
b766de4f18
commit
8830d23388
@ -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
|
||||
|
@ -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
|
||||
}
|
||||
|
||||
|
@ -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)
|
||||
|
Loading…
Reference in New Issue
Block a user