Skip to content

Commit

Permalink
Push failure marking behavior out of worker and into the backend
Browse files Browse the repository at this point in the history
  • Loading branch information
betamatt committed Jun 3, 2011
1 parent 91cc5de commit e842215
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 1 deletion.
4 changes: 4 additions & 0 deletions lib/delayed/backend/base.rb
Original file line number Diff line number Diff line change
Expand Up @@ -121,6 +121,10 @@ def max_attempts
payload_object.max_attempts if payload_object.respond_to?(:max_attempts)
end

def fail!
update_attributes(:failed_at => self.class.db_time_now)
end

protected

def set_default_run_at
Expand Down
2 changes: 1 addition & 1 deletion lib/delayed/worker.rb
Original file line number Diff line number Diff line change
Expand Up @@ -152,7 +152,7 @@ def failed(job)
if job.respond_to?(:on_permanent_failure)
warn "[DEPRECATION] The #on_permanent_failure hook has been renamed to #failure."
end
self.class.destroy_failed_jobs ? job.destroy : job.update_attributes(:failed_at => Delayed::Job.db_time_now)
self.class.destroy_failed_jobs ? job.destroy : job.fail!
end

def say(text, level = Logger::INFO)
Expand Down

0 comments on commit e842215

Please sign in to comment.