Module: Puller
- Defined in:
- lib/harvester/puller.rb
Class Method Summary collapse
- .activate(name, endpoint, timeout) ⇒ Object
- .fetch_data(endpoint) ⇒ Object
- .send(data, topic) ⇒ Object
Class Method Details
.activate(name, endpoint, timeout) ⇒ Object
26 27 28 29 30 31 |
# File 'lib/harvester/puller.rb', line 26 def self.activate(name, endpoint, timeout) loop do puts send fetch_data(endpoint), name sleep timeout end end |
.fetch_data(endpoint) ⇒ Object
10 11 12 13 14 15 16 17 18 19 |
# File 'lib/harvester/puller.rb', line 10 def self.fetch_data(endpoint) conn = Faraday.new(url: endpoint) do |faraday| faraday.adapter :excon faraday.headers['X-Api-Key'] = Settings.newrelic_key end conn.get.body # rescue Exception => e # puts "Puller#fetch_data" # puts "#{e.inspect}: #{e.message}" end |
.send(data, topic) ⇒ Object
21 22 23 24 |
# File 'lib/harvester/puller.rb', line 21 def self.send(data, topic) # puts "Puller#send" @broadcaster.send data, topic: topic end |