Class: FeedJob

Inherits:
Struct
  • Object
show all
Defined in:
app/jobs/feed_job.rb

Overview

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

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#raw_messageObject

Returns the value of attribute raw_message

Returns:

  • (Object)

    the current value of raw_message



14
15
16
# File 'app/jobs/feed_job.rb', line 14

def raw_message
  @raw_message
end

Instance Method Details

#destroy_failed_jobs?Boolean

Returns:

  • (Boolean)


23
24
25
# File 'app/jobs/feed_job.rb', line 23

def destroy_failed_jobs?
  false
end

#max_attemptsObject



19
20
21
# File 'app/jobs/feed_job.rb', line 19

def max_attempts
  2
end

#performObject



15
16
17
# File 'app/jobs/feed_job.rb', line 15

def perform
  Renalware::Feeds.message_processor.call(raw_message)
end

#reschedule_at(current_time, attempts) ⇒ Object

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



34
35
36
# File 'app/jobs/feed_job.rb', line 34

def reschedule_at(current_time, attempts)
  current_time + ((attempts**4) + 1).hours
end