Class: Workerholic::JobRetry
- Inherits:
-
Object
- Object
- Workerholic::JobRetry
- Defined in:
- lib/workerholic/job_retry.rb
Instance Attribute Summary collapse
-
#job ⇒ Object
readonly
Returns the value of attribute job.
-
#sorted_set ⇒ Object
readonly
Returns the value of attribute sorted_set.
-
#stats_storage ⇒ Object
readonly
Returns the value of attribute stats_storage.
Instance Method Summary collapse
-
#initialize(options = {}) ⇒ JobRetry
constructor
A new instance of JobRetry.
- #retry ⇒ Object
Constructor Details
#initialize(options = {}) ⇒ JobRetry
Returns a new instance of JobRetry.
5 6 7 8 |
# File 'lib/workerholic/job_retry.rb', line 5 def initialize(={}) @job = [:job] @sorted_set = [:sorted_set] || SortedSet.new('workerholic:scheduled_jobs') end |
Instance Attribute Details
#job ⇒ Object (readonly)
Returns the value of attribute job.
3 4 5 |
# File 'lib/workerholic/job_retry.rb', line 3 def job @job end |
#sorted_set ⇒ Object (readonly)
Returns the value of attribute sorted_set.
3 4 5 |
# File 'lib/workerholic/job_retry.rb', line 3 def sorted_set @sorted_set end |
#stats_storage ⇒ Object (readonly)
Returns the value of attribute stats_storage.
3 4 5 |
# File 'lib/workerholic/job_retry.rb', line 3 def stats_storage @stats_storage end |
Instance Method Details
#retry ⇒ Object
10 11 12 13 14 15 16 |
# File 'lib/workerholic/job_retry.rb', line 10 def retry return if job.retry_count >= 5 increment_retry_count schedule_job_for_retry sorted_set.add(JobSerializer.serialize(job), job.execute_at) end |