Class: Ring::SQA::Sender

Inherits:
Poller
  • Object
show all
Defined in:
lib/ring/sqa/poller/sender.rb

Constant Summary collapse

INTERVAL =

duration pinging all nodes should take

30
INTER_NODE_GAP =

delay to sleep between each node

0.01

Constants inherited from Poller

Poller::MAX_READ

Instance Method Summary collapse

Methods inherited from Poller

#address, #port, #udp_socket

Instance Method Details

#runObject



8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
# File 'lib/ring/sqa/poller/sender.rb', line 8

def run
  udp = udp_socket
  loop do
    loop_start = Time.now
    @nodes.all.each do |node, _|
      query node, udp
      sleep INTER_NODE_GAP
    end
    duration = Time.now-loop_start
    if duration < 0
      Log.warn "Send loop duration was negative - ntp sync?"
    elsif duration < INTERVAL
      sleep INTERVAL-duration
    else
      Log.warn "Send loop took longer than #{INTERVAL}s"
    end
  end
  udp.close
end