Class: AutoScaleWorkers::Collector

Inherits:
Object
  • Object
show all
Defined in:
lib/auto_scale_workers/collector.rb

Class Method Summary collapse

Class Method Details

.start(interval, queues = []) ⇒ Object



21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
# File 'lib/auto_scale_workers/collector.rb', line 21

def self.start(interval, queues = [])
  puts "Stating Collector"
  Concurrent::TimerTask.new(execution_interval: interval) do
    # Chame sua API aqui
    token = AutoScaleWorkers.config[:token]
    api_url = AutoScaleWorkers.config[:api_url]
    body = SidekiqCollector.get_stat(queues).to_json
    response = HTTParty.post(api_url, body: body, headers: { 'Content-Type' => 'application/json' })
    if response.success?
      puts "Posted do ASW"
    else
      raise "Erro na requisição: #{response.code}"
    end
  end.execute
rescue StandardError => e
  puts "Erro: #{e.message}"
end