module EM::Nodes::Commands
Constants
- COMMAND_PREFIX
Public Instance Methods
method_missing(method, *args)
click to toggle source
Calls superclass method
# File lib/em-nodes/commands.rb, line 21 def method_missing(method, *args) method = method.to_s unless method.start_with?(COMMAND_PREFIX) EM::Nodes.logger.warn { "unknown send :#{method} #{args.inspect}" } super(method, *args) return end if @alive send_command(method[5..-1], args) else EM::Nodes.logger.error { "failed command attempt #{method}, connection dead" } end end
receive_object(h)
click to toggle source
# File lib/em-nodes/commands.rb, line 3 def receive_object(h) method, args = h method = 'on_' + method t = Time.now send(method, *args) EM::Nodes.logger.debug { "<= #{method} #{args.inspect} (#{Time.now - t}s)" } rescue Object => ex EM::Nodes.exception(ex) end
send_command(method, args)
click to toggle source
# File lib/em-nodes/commands.rb, line 14 def send_command(method, args) EM::Nodes.logger.debug { "=> #{method}" } EM.schedule { send_object [method.to_s, args] } end