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.1.1 app/jobs/feed_job.rb
renalware-core-2.1.0 app/jobs/feed_job.rb
renalware-core-2.0.167 app/jobs/feed_job.rb
renalware-core-2.0.166 app/jobs/feed_job.rb
renalware-core-2.0.165 app/jobs/feed_job.rb
renalware-core-2.0.164 app/jobs/feed_job.rb
renalware-core-2.0.163 app/jobs/feed_job.rb
renalware-core-2.0.162 app/jobs/feed_job.rb
renalware-core-2.0.161 app/jobs/feed_job.rb
renalware-core-2.0.160 app/jobs/feed_job.rb
renalware-core-2.0.159 app/jobs/feed_job.rb
renalware-core-2.0.158 app/jobs/feed_job.rb
renalware-core-2.0.157 app/jobs/feed_job.rb
renalware-core-2.0.156 app/jobs/feed_job.rb
renalware-core-2.0.155 app/jobs/feed_job.rb
renalware-core-2.0.153 app/jobs/feed_job.rb
renalware-core-2.0.152 app/jobs/feed_job.rb
renalware-core-2.0.151 app/jobs/feed_job.rb
renalware-core-2.0.149 app/jobs/feed_job.rb
renalware-core-2.0.148 app/jobs/feed_job.rb