mirror of
https://github.com/hibiken/asynq.git
synced 2025-08-19 15:08:55 +08:00
Rename rdb methods to enqueue scheduled, retry, and dead tasks
This commit is contained in:
@@ -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
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user