Method: Tengine::Core::Bootstrap#start_connection_test

Defined in:
lib/tengine/core/bootstrap.rb

#start_connection_test(mq) ⇒ Object



94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
# File 'lib/tengine/core/bootstrap.rb', line 94

def start_connection_test(mq)
  require 'timeout'
  timeout(10) do
    connection_test_completed = false
    Tengine.callback_for_test = lambda do |event_type_name|
      case event_type_name
      when :foo then
        Tengine::Core.stdout_logger.info("handing :foo successfully.")
      when :bar then
        Tengine::Core.stdout_logger.info("handing :bar successfully.")
        connection_test_completed = true
      else
        Tengine::Core.stderr_logger.error("Unexpected event: #{event_type_name}")
      end
    end
    Tengine::Event.instance_variable_set(:@mq_suite, mq)
    Tengine::Event.fire(:foo, :level_key => :info, :keep_connection => true)
    loop do
      sleep(0.1)
      return if connection_test_completed
    end
  end
end