~scooter/queue

f2407cf2e90f6c26e2d7b435528dbe517ad23211 — Bryan Burke 3 years ago dce6272 master
improve docs for Requeue
1 files changed, 3 insertions(+), 1 deletions(-)

M queue.go
M queue.go => queue.go +3 -1
@@ 89,7 89,9 @@ func Length(db DB, action string) (int, error) {
	return i, nil
}

// RequeueExpired will re-add tasks to the queue when their TTL has expired
// RequeueExpired will re-add tasks to the queue when their TTL has expired.  Note that you do not have to call this function
// manually unless you want to requeue immediately.  Expired tasks are automatically requeued when a subsequent database operation is
// performed.  For very low traffic queues, you may want to call this periodically to limit worst case delay before requeue.
func RequeueExpired(db DB) (int, error) {
	now := time.Now().Unix()
	res, err := db.Exec("UPDATE queue SET expires = 0, tries = tries + 1 WHERE expires > 0 AND expires < ?", now)