Class: Workerholic::JobProcessor
- Inherits:
-
Object
- Object
- Workerholic::JobProcessor
- Defined in:
- lib/workerholic/job_processor.rb
Instance Attribute Summary collapse
-
#serialized_job ⇒ Object
readonly
Returns the value of attribute serialized_job.
Instance Method Summary collapse
-
#initialize(serialized_job) ⇒ JobProcessor
constructor
A new instance of JobProcessor.
- #process ⇒ Object
Constructor Details
#initialize(serialized_job) ⇒ JobProcessor
Returns a new instance of JobProcessor.
5 6 7 8 |
# File 'lib/workerholic/job_processor.rb', line 5 def initialize(serialized_job) @serialized_job = serialized_job @logger = LogManager.new end |
Instance Attribute Details
#serialized_job ⇒ Object (readonly)
Returns the value of attribute serialized_job.
3 4 5 |
# File 'lib/workerholic/job_processor.rb', line 3 def serialized_job @serialized_job end |
Instance Method Details
#process ⇒ Object
10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 |
# File 'lib/workerholic/job_processor.rb', line 10 def process job = JobSerializer.deserialize(serialized_job) job.statistics.started_at = Time.now.to_f job_result = job.perform job.statistics.completed_at = Time.now.to_f StatsStorage.save_job('completed_jobs', job) StatsStorage.update_historical_stats('completed_jobs', job.klass.to_s) # @logger.info("Completed: your job from class #{job.klass} was completed on #{job.statistics.completed_at}.") # forces AR to release idle connections back to the pool ActiveRecord::Base.clear_active_connections! if defined?(Rails) job_result rescue Exception => e job.statistics.errors.push([e.class, e.]) retry_job(job, e) end |