class Blocker
Constants
- BLOCKER_PORT_START
- CTX
Public Class Methods
new(rank:, debug: false)
click to toggle source
# File lib/rpareia/blocker.rb, line 10 def initialize(rank:, debug: false) @rank = rank @debug = debug @port = BLOCKER_PORT_START + @rank end
Public Instance Methods
connect()
click to toggle source
# File lib/rpareia/blocker.rb, line 44 def connect @socket = CTX.socket(:ROUTER) @socket.verbose = @debug @socket.bind("tcp://*:#{@port}") end
start()
click to toggle source
# File lib/rpareia/blocker.rb, line 16 def start start_hb connect total = 0 loop do msg = @socket.recv next if msg.nil? || msg[0] == "\x00" if msg != "EOF" total += 1 else puts "TOTAL=#{total}" end end end
start_hb()
click to toggle source
# File lib/rpareia/blocker.rb, line 36 def start_hb Thread.new do loop do Heartbeat.check(addr: "tcp://*:#{2 * @port}", ctx: CTX, type: 'server', debug: @debug) end end end