Class: Lambdakiq::Job
- Inherits:
-
Object
- Object
- Lambdakiq::Job
- Defined in:
- lib/lambdakiq/job.rb
Instance Attribute Summary collapse
-
#error ⇒ Object
readonly
Returns the value of attribute error.
-
#record ⇒ Object
readonly
Returns the value of attribute record.
Class Method Summary collapse
Instance Method Summary collapse
- #active_job ⇒ Object
- #execute ⇒ Object
- #executions ⇒ Object
-
#initialize(record) ⇒ Job
constructor
A new instance of Job.
- #job_data ⇒ Object
- #perform ⇒ Object
- #queue ⇒ Object
Constructor Details
Instance Attribute Details
#error ⇒ Object (readonly)
Returns the value of attribute error.
4 5 6 |
# File 'lib/lambdakiq/job.rb', line 4 def error @error end |
#record ⇒ Object (readonly)
Returns the value of attribute record.
4 5 6 |
# File 'lib/lambdakiq/job.rb', line 4 def record @record end |
Class Method Details
Instance Method Details
#active_job ⇒ Object
31 32 33 |
# File 'lib/lambdakiq/job.rb', line 31 def active_job @active_job ||= ActiveJob::Base.deserialize(job_data) end |
#execute ⇒ Object
51 52 53 54 55 56 57 |
# File 'lib/lambdakiq/job.rb', line 51 def execute ActiveJob::Base.execute(job_data) rescue Exception => e increment_executions perform_error(e) end |
#executions ⇒ Object
39 40 41 |
# File 'lib/lambdakiq/job.rb', line 39 def executions active_job.executions end |
#job_data ⇒ Object
24 25 26 27 28 29 |
# File 'lib/lambdakiq/job.rb', line 24 def job_data @job_data ||= JSON.parse(record.body).tap do |data| data['provider_job_id'] = record. data['executions'] = record.receive_count - 1 end end |
#perform ⇒ Object
43 44 45 46 47 48 49 |
# File 'lib/lambdakiq/job.rb', line 43 def perform if fifo_delay? fifo_delay raise FifoDelayError, active_job.job_id end execute end |