Class: Jobs::HttpMulti

Inherits:
Base
  • Object
show all
Defined in:
app/models/jobs/http_multi.rb

Constant Summary

MAX_RETRIES =
3

Constants inherited from Base

Base::DUMB_ERROR_MESSAGES

Class Method Summary (collapse)

Methods inherited from Base

suppress_annoying_errors

Class Method Details

+ (Object) perform(user_id, encoded_object_xml, person_ids, dispatcher_class_as_string, retry_count = 0)



15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
# File 'app/models/jobs/http_multi.rb', line 15

def self.perform(user_id, encoded_object_xml, person_ids, dispatcher_class_as_string, retry_count=0)
  user = User.find(user_id)
  people = Person.where(:id => person_ids)

  dispatcher = dispatcher_class_as_string.constantize
  hydra = HydraWrapper.new(user, people, encoded_object_xml, dispatcher)

  hydra.enqueue_batch
  hydra.run

  unless hydra.failed_people.empty?
    if retry_count < MAX_RETRIES
      Resque.enqueue(Jobs::HttpMulti, user_id, encoded_object_xml, hydra.failed_people, dispatcher_class_as_string, retry_count + 1 )
    else
      Rails.logger.info("event=http_multi_abandon sender_id=#{user_id} failed_recipient_ids='[#{person_ids.join(', ')}] '")
    end
  end
end