2
0
mirror of https://github.com/hibiken/asynq.git synced 2026-05-01 05:25:52 +08:00

Refactor forwarding of scheduled tasks

This commit is contained in:
Ken Hibino
2019-12-04 07:14:37 -08:00
parent 318b24b3b8
commit 4684f961c0
5 changed files with 45 additions and 24 deletions

View File

@@ -15,17 +15,13 @@ type poller struct {
// poll interval on average
avgInterval time.Duration
// redis ZSETs to poll
zsets []string
}
func newPoller(r *rdb.RDB, avgInterval time.Duration, zsets []string) *poller {
func newPoller(r *rdb.RDB, avgInterval time.Duration) *poller {
return &poller{
rdb: r,
done: make(chan struct{}),
avgInterval: avgInterval,
zsets: zsets,
}
}
@@ -52,9 +48,7 @@ func (p *poller) start() {
}
func (p *poller) exec() {
for _, zset := range p.zsets {
if err := p.rdb.Forward(zset); err != nil {
log.Printf("[ERROR] could not forward scheduled tasks from %q: %v\n", zset, err)
}
if err := p.rdb.CheckScheduled(); err != nil {
log.Printf("[ERROR] could not forward scheduled tasks: %v\n", err)
}
}