Permalink
Browse files

whitespace

  • Loading branch information...
bkeepers committed Nov 12, 2010
1 parent 626b5e2 commit b0e1c7e215d58a5d6457218d31d95a7af15e56e9
Showing with 11 additions and 11 deletions.
  1. +2 −2 lib/delayed/backend/base.rb
  2. +9 −9 lib/delayed/worker.rb
@@ -105,11 +105,11 @@ def hook(name, *args)
end
def reschedule_at
- payload_object.respond_to?(:reschedule_at) ?
+ payload_object.respond_to?(:reschedule_at) ?
payload_object.reschedule_at(self.class.db_time_now, attempts) :
self.class.db_time_now + (attempts ** 4) + 5
end
-
+
protected
def set_default_run_at
View
@@ -16,7 +16,7 @@ class Worker
# (perhaps to inspect the reason for the failure), set this to false.
cattr_accessor :destroy_failed_jobs
self.destroy_failed_jobs = true
-
+
self.logger = if defined?(Rails)
Rails.logger
elsif defined?(RAILS_DEFAULT_LOGGER)
@@ -25,9 +25,9 @@ class Worker
# name_prefix is ignored if name is set directly
attr_accessor :name_prefix
-
+
cattr_reader :backend
-
+
def self.backend=(backend)
if backend.is_a? Symbol
require "delayed/backend/#{backend}"
@@ -36,7 +36,7 @@ def self.backend=(backend)
@@backend = backend
silence_warnings { ::Delayed.const_set(:Job, backend) }
end
-
+
def self.guess_backend
self.backend ||= :active_record if defined?(ActiveRecord)
end
@@ -92,7 +92,7 @@ def start
ensure
Delayed::Job.clear_locks!(name)
end
-
+
# Do num jobs and return stats on success/failure.
# Exit early if interrupted.
def work_off(num = 100)
@@ -112,7 +112,7 @@ def work_off(num = 100)
return [success, failure]
end
-
+
def run(job)
runtime = Benchmark.realtime do
Timeout.timeout(self.class.max_run_time.to_i) { job.invoke_job }
@@ -124,7 +124,7 @@ def run(job)
handle_failed_job(job, e)
return false # work failed
end
-
+
# Reschedule the job in the future (when a job fails).
# Uses an exponential scale depending on the number of failed attempts.
def reschedule(job, time = nil)
@@ -150,13 +150,13 @@ def say(text, level = Logger::INFO)
end
protected
-
+
def handle_failed_job(job, error)
job.last_error = "{#{error.message}\n#{error.backtrace.join('\n')}"
say "#{job.name} failed with #{error.class.name}: #{error.message} - #{job.attempts} failed attempts", Logger::ERROR
reschedule(job)
end
-
+
# Run the next job we can get an exclusive lock on.
# If no jobs are left we return nil
def reserve_and_run_one_job

0 comments on commit b0e1c7e

Please sign in to comment.