Skip to content

Commit

Permalink
Update README.md - document reschedule_at
Browse files Browse the repository at this point in the history
  • Loading branch information
Nowaker committed Oct 4, 2014
1 parent a4c3d65 commit 3f43042
Showing 1 changed file with 14 additions and 1 deletion.
15 changes: 14 additions & 1 deletion README.md
Expand Up @@ -289,6 +289,19 @@ NewsletterJob = Struct.new(:text, :emails) do
end
```

On error, the job is scheduled again in 5 seconds + N ** 4, where N is the number of retries. This behavior can be overridden when you define `reschedule_at` method.

```ruby
NewsletterJob = Struct.new(:text, :emails) do
def perform
emails.each { |e| NewsletterMailer.deliver_text_to_email(text, e) }
end

def reschedule_at(current_time, attempts)
current_time + 5.seconds
end
end
```

Hooks
=====
Expand Down Expand Up @@ -345,7 +358,7 @@ create_table :delayed_jobs, :force => true do |table|
end
```

On failure, the job is scheduled again in 5 seconds + N ** 4, where N is the number of retries.
On failure, unless `reschedule_at` is defined, the job is scheduled again in 5 seconds + N ** 4, where N is the number of retries.

The default `Worker.max_attempts` is 25. After this, the job either deleted (default), or left in the database with "failed_at" set.
With the default of 25 attempts, the last retry will be 20 days later, with the last interval being almost 100 hours.
Expand Down

0 comments on commit 3f43042

Please sign in to comment.