Module: Delayed::Backend::Base
- Included in:
- ActiveRecord::Job, DataMapper::Job, MongoMapper::Job
- Defined in:
- lib/delayed/backend/base.rb
Defined Under Namespace
Modules: ClassMethods
Constant Summary collapse
- ParseObjectFromYaml =
/\!ruby\/\w+\:([^\s]+)/
Class Method Summary collapse
Instance Method Summary collapse
- #failed? ⇒ Boolean (also: #failed)
-
#invoke_job ⇒ Object
Moved into its own method so that new_relic can trace it.
- #max_attempts ⇒ Object
- #name ⇒ Object
- #payload_object ⇒ Object
- #payload_object=(object) ⇒ Object
- #reschedule_at ⇒ Object
-
#unlock ⇒ Object
Unlock this job (note: not saved to DB).
Class Method Details
.included(base) ⇒ Object
4 5 6 |
# File 'lib/delayed/backend/base.rb', line 4 def self.included(base) base.extend ClassMethods end |
Instance Method Details
#failed? ⇒ Boolean Also known as: failed
45 46 47 |
# File 'lib/delayed/backend/base.rb', line 45 def failed? failed_at end |
#invoke_job ⇒ Object
Moved into its own method so that new_relic can trace it.
70 71 72 |
# File 'lib/delayed/backend/base.rb', line 70 def invoke_job payload_object.perform end |
#max_attempts ⇒ Object
86 87 88 |
# File 'lib/delayed/backend/base.rb', line 86 def max_attempts payload_object.max_attempts if payload_object.respond_to?(:max_attempts) end |
#name ⇒ Object
50 51 52 53 54 55 56 57 58 59 |
# File 'lib/delayed/backend/base.rb', line 50 def name @name ||= begin payload = payload_object if payload.respond_to?(:display_name) payload.display_name else payload.class.name end end end |
#payload_object ⇒ Object
65 66 67 |
# File 'lib/delayed/backend/base.rb', line 65 def payload_object @payload_object ||= deserialize(self['handler']) end |
#payload_object=(object) ⇒ Object
61 62 63 |
# File 'lib/delayed/backend/base.rb', line 61 def payload_object=(object) self['handler'] = object.to_yaml end |
#reschedule_at ⇒ Object
80 81 82 83 84 |
# File 'lib/delayed/backend/base.rb', line 80 def 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 |
#unlock ⇒ Object
Unlock this job (note: not saved to DB)
75 76 77 78 |
# File 'lib/delayed/backend/base.rb', line 75 def unlock self.locked_at = nil self.locked_by = nil end |