Class: SnowAgent::Sender
- Inherits:
-
Object
- Object
- SnowAgent::Sender
- Defined in:
- lib/snowagent/sender.rb
Instance Method Summary collapse
-
#initialize(queue, conf) ⇒ Sender
constructor
A new instance of Sender.
- #process ⇒ Object
- #run ⇒ Object
- #send_data ⇒ Object
Constructor Details
Instance Method Details
#process ⇒ Object
15 16 17 18 19 20 21 22 23 24 25 26 27 |
# File 'lib/snowagent/sender.rb', line 15 def process # Pop metrics from the queue while !@queue.empty? @metrics << @queue.pop end if @send_at <= Time.now.to_i @send_at = Time.now.to_i + @conf.send_interval send_data if @metrics.any? end sleep 1 end |
#run ⇒ Object
11 12 13 |
# File 'lib/snowagent/sender.rb', line 11 def run loop { process } end |
#send_data ⇒ Object
29 30 31 32 33 34 35 |
# File 'lib/snowagent/sender.rb', line 29 def send_data # TODO: # * requeue data on failure @service.post_data({ metrics: @metrics.map(&:to_h) }) @metrics.clear end |