Sha256: 7231879c9cfa24c7a9a9c1af740fd56ee1b00eea9b7cc57914525504a086ee74

Contents?: true

Size: 624 Bytes

Versions: 3

Compression:

Stored size: 624 Bytes

Contents

# The purpose of this job is to find journeys which have, for whatever reason, remained in the
# `performing` state for far longer than the journey is supposed to. At the moment it assumes
# any journey that stayed in `performing` for longer than 1 hour has hung. Add this job to your
# cron table and perform it regularly.
class StepperMotor::ReapHungJourneysJob < ActiveJob::Base
  def perform
    StepperMotor::Journey.where("state = 'performing' AND updated_at < ?", 1.hour.ago).find_each do |hung_journey|
      hung_journey.update!(state: "ready")
      StepperMotor.scheduler.schedule(hung_journey)
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
stepper_motor-0.1.2 lib/stepper_motor/reap_hung_journeys_job.rb
stepper_motor-0.1.1 lib/stepper_motor/reap_hung_journeys_job.rb
stepper_motor-0.1.0 lib/stepper_motor/reap_hung_journeys_job.rb