Module: Aranha::Address::Scheduling
- Included in:
- Aranha::Address
- Defined in:
- app/models/aranha/address/scheduling.rb
Defined Under Namespace
Modules: ClassMethods
Instance Method Summary collapse
- #allow_retry? ⇒ Boolean
- #check_scheduling ⇒ Object
- #expired?(time = ::Time.zone.now) ⇒ Boolean
- #init_scheduling ⇒ Object
- #schedule? ⇒ Boolean
Instance Method Details
#allow_retry? ⇒ Boolean
38 39 40 |
# File 'app/models/aranha/address/scheduling.rb', line 38 def allow_retry? tries_count < ::Aranha::Processor::DEFAULT_MAX_TRIES end |
#check_scheduling ⇒ Object
17 18 19 20 21 22 23 24 25 26 27 |
# File 'app/models/aranha/address/scheduling.rb', line 17 def check_scheduling ::ActiveRecord::Base.transaction do return unless schedule? job = ::Delayed::Job.enqueue( ::Aranha::Address::DelayedJob.new(id), queue: ::Aranha::Rails::Process::QUEUE ) update!(delayed_job: job) end end |
#expired?(time = ::Time.zone.now) ⇒ Boolean
29 30 31 |
# File 'app/models/aranha/address/scheduling.rb', line 29 def expired?(time = ::Time.zone.now) time >= (created_at + timeout) end |
#init_scheduling ⇒ Object
33 34 35 36 |
# File 'app/models/aranha/address/scheduling.rb', line 33 def init_scheduling update!(tries_count: 0, last_error: nil) unless processed? check_scheduling end |
#schedule? ⇒ Boolean
42 43 44 |
# File 'app/models/aranha/address/scheduling.rb', line 42 def schedule? processed_at.blank? && allow_retry? && delayed_job.blank? && enabled? end |