Sha256: 3417d57fb07f0a84e429d62420fab411ce463d1d1a2792164266aa5f1f4d14cd

Contents?: true

Size: 980 Bytes

Versions: 50

Compression:

Stored size: 980 Bytes

Contents

# frozen_string_literal: true

# To create outside of Rails, insert a row with values for the following columns
# into the `delayed_jobs` table:
#
#     handler: {see h7_message_example.yml}
#     run_at: {current_time e.g. NOW() AT TIME ZONE 'UTC'}
#
# Notes:
#
# - the key `raw_message` for the `handler` column must have line endings "\n"
# - to run delayed_jobs see in development use rake jobs:work
#
FeedJob = Struct.new(:raw_message) do
  def perform
    Renalware::Feeds.message_processor.call(raw_message)
  end

  def max_attempts
    2
  end

  def destroy_failed_jobs?
    false
  end

  # Reschedule after an error. No point trying straight away, so try at these intervals:
  # After attempt no. Wait for hours
  # ---------------------------
  # 1                  2
  # 2                  17
  # Then give up.
  # Note e.g. attempts**4 == attempts to the power of 4
  def reschedule_at(current_time, attempts)
    current_time + ((attempts**4) + 1).hours
  end
end

Version data entries

50 entries across 50 versions & 1 rubygems

Version Path
renalware-core-2.0.147 app/jobs/feed_job.rb
renalware-core-2.0.146 app/jobs/feed_job.rb
renalware-core-2.0.145 app/jobs/feed_job.rb
renalware-core-2.0.144 app/jobs/feed_job.rb
renalware-core-2.0.143 app/jobs/feed_job.rb
renalware-core-2.0.142 app/jobs/feed_job.rb
renalware-core-2.0.141 app/jobs/feed_job.rb
renalware-core-2.0.140 app/jobs/feed_job.rb
renalware-core-2.0.139 app/jobs/feed_job.rb
renalware-core-2.0.138 app/jobs/feed_job.rb
renalware-core-2.0.137 app/jobs/feed_job.rb
renalware-core-2.0.136 app/jobs/feed_job.rb
renalware-core-2.0.135 app/jobs/feed_job.rb
renalware-core-2.0.134 app/jobs/feed_job.rb
renalware-core-2.0.133 app/jobs/feed_job.rb
renalware-core-2.0.132 app/jobs/feed_job.rb
renalware-core-2.0.131 app/jobs/feed_job.rb
renalware-core-2.0.130 app/jobs/feed_job.rb
renalware-core-2.0.129 app/jobs/feed_job.rb
renalware-core-2.0.128 app/jobs/feed_job.rb