Module: SolidQueue::Job::Retryable
- Extended by:
- ActiveSupport::Concern
- Defined in:
- lib/solid_queue_mongoid/models/job/retryable.rb
Instance Method Summary collapse
- #can_retry? ⇒ Boolean
- #failed_with(exception) ⇒ Object
- #reset_execution_counters ⇒ Object
- #retry ⇒ Object
Instance Method Details
#can_retry? ⇒ Boolean
16 17 18 19 20 |
# File 'lib/solid_queue_mongoid/models/job/retryable.rb', line 16 def can_retry? max = read_attribute(:max_retries) || 0 count = read_attribute(:retry_count) || 0 count < max end |
#failed_with(exception) ⇒ Object
22 23 24 25 26 27 28 29 30 31 32 33 34 |
# File 'lib/solid_queue_mongoid/models/job/retryable.rb', line 22 def failed_with(exception) FailedExecution.create!(job_id: id, exception: exception) rescue Mongoid::Errors::Validations, Mongo::Error::OperationFailure => e raise unless duplicate_key_error?(e) existing = FailedExecution.find_by(job_id: id) if existing existing.exception = exception existing.save! else retry end end |
#reset_execution_counters ⇒ Object
36 37 38 39 40 41 42 |
# File 'lib/solid_queue_mongoid/models/job/retryable.rb', line 36 def reset_execution_counters return unless arguments.is_a?(Hash) arguments["executions"] = 0 arguments["exception_executions"] = {} save! end |
#retry ⇒ Object
12 13 14 |
# File 'lib/solid_queue_mongoid/models/job/retryable.rb', line 12 def retry failed_execution&.retry end |