2
0
mirror of https://github.com/hibiken/asynq.git synced 2024-12-24 23:02:18 +08:00

Rename to CheckAndEnqueue

This commit is contained in:
Ken Hibino 2019-12-04 07:28:57 -08:00
parent af1dcf5044
commit 28bfb6d83a
4 changed files with 9 additions and 9 deletions

View File

@ -18,7 +18,7 @@ func setup(t *testing.T) *redis.Client {
t.Helper()
r := redis.NewClient(&redis.Options{
Addr: "localhost:6379",
DB: 2,
DB: 15,
})
// Start each test with a clean slate.
if err := r.FlushDB().Err(); err != nil {

View File

@ -229,9 +229,9 @@ func (r *RDB) RestoreUnfinished() error {
return err
}
// CheckScheduled checks for all scheduled tasks and moves any tasks that
// have to be processed to the queue.
func (r *RDB) CheckScheduled() error {
// CheckAndEnqueue checks for all scheduled tasks and enqueues any tasks that
// have to be processed.
func (r *RDB) CheckAndEnqueue() error {
delayed := []string{Scheduled, Retry}
for _, zset := range delayed {
if err := r.forward(zset); err != nil {

View File

@ -323,7 +323,7 @@ func TestRestoreUnfinished(t *testing.T) {
}
}
func TestCheckScheduled(t *testing.T) {
func TestCheckAndEnqueue(t *testing.T) {
r := setup(t)
t1 := randomTask("send_email", "default", nil)
t2 := randomTask("generate_csv", "default", nil)
@ -335,8 +335,8 @@ func TestCheckScheduled(t *testing.T) {
initScheduled []*redis.Z // tasks to be processed later
initRetry []*redis.Z // tasks to be retired later
wantQueued []*TaskMessage // queue after calling forward
wantScheduled []*TaskMessage // tasks in scheduled queue after calling CheckScheduled
wantRetry []*TaskMessage // tasks in retry queue after calling CheckScheduled
wantScheduled []*TaskMessage // tasks in scheduled queue after calling the method
wantRetry []*TaskMessage // tasks in retry queue after calling the method
}{
{
initScheduled: []*redis.Z{
@ -384,7 +384,7 @@ func TestCheckScheduled(t *testing.T) {
continue
}
err := r.CheckScheduled()
err := r.CheckAndEnqueue()
if err != nil {
t.Errorf("(*RDB).CheckScheduled() = %v, want nil", err)
continue

View File

@ -48,7 +48,7 @@ func (p *poller) start() {
}
func (p *poller) exec() {
if err := p.rdb.CheckScheduled(); err != nil {
if err := p.rdb.CheckAndEnqueue(); err != nil {
log.Printf("[ERROR] could not forward scheduled tasks: %v\n", err)
}
}