Class: Micron::Runner::LivenessChecker::Pong

Inherits:
Object
  • Object
show all
Includes:
Debug
Defined in:
lib/micron/runner/liveness_checker/pong.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from Debug

#debug

Constructor Details

#initialize(reader, writer) ⇒ Pong

Returns a new instance of Pong.



11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
# File 'lib/micron/runner/liveness_checker/pong.rb', line 11

def initialize(reader, writer)
  @thread = Thread.new(reader, writer) { |reader, writer|

    Thread.current[:name] = "ponger"
    debug "thread started"

    begin
      writer.sync = true
      while line = reader.readline
        debug "got ping request, replying"
        writer.puts "pong"
      end

    rescue Exception => ex
      debug "caught error: #{Micron.dump_ex(ex)}"
    end

    debug "thread exiting from #{$$}"
  }
end

Instance Attribute Details

#threadObject (readonly)

Returns the value of attribute thread.



9
10
11
# File 'lib/micron/runner/liveness_checker/pong.rb', line 9

def thread
  @thread
end