Module: Gauge::Runtime Private

Defined in:
lib/gauge_runtime.rb

This module is part of a private API. You should avoid using this module if possible, as it may be removed or be changed in the future.

Constant Summary collapse

DEFAULT_IMPLEMENTATIONS_DIR_PATH =

This constant is part of a private API. You should avoid using this constant if possible, as it may be removed or be changed in the future.

Util.get_step_implementation_dir

Class Method Summary collapse

Class Method Details

.dispatch_messages(socket) ⇒ Object

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.



35
36
37
38
39
40
41
42
43
44
45
46
# File 'lib/gauge_runtime.rb', line 35

def self.dispatch_messages(socket)
  while (!socket.eof?)
    len = Connector.message_length(socket)
    data = socket.read len
    message = Messages::Message.parse(data)
    handle_message(socket, message)
    if message.messageType == Messages::Message::MessageType::KillProcessRequest || message.messageType == Messages::Message::MessageType::ExecutionEnding
      socket.close
      return
    end
  end
end

.handle_message(socket, message) ⇒ Object

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.



49
50
51
52
53
54
55
56
57
58
59
# File 'lib/gauge_runtime.rb', line 49

def self.handle_message(socket, message)
  if !MessageProcessor.is_valid_message(message)
    Gauge::Log.error "Invalid message received : #{message}"
    execution_status_response = Messages::ExecutionStatusResponse.new(:executionResult => Messages::ProtoExecutionResult.new(:failed => true, :executionTime => 0))
    message = Messages::Message.new(:messageType => Messages::Message::MessageType::ExecutionStatusResponse, :messageId => message.messageId, :executionStatusResponse => execution_status_response)
    write_message(socket, message)
  else
    response = MessageProcessor.process_message message
    write_message(socket, response) if response
  end
end

.port_from_env_variable(env_variable) ⇒ Object

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.



68
69
70
71
72
73
74
# File 'lib/gauge_runtime.rb', line 68

def self.port_from_env_variable(env_variable)
  port = ENV[env_variable]
  if port.nil?
    raise RuntimeError, "Could not find Env variable :#{env_variable}"
  end
  return port
end

.write_message(socket, message) ⇒ Object

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.



61
62
63
64
65
66
# File 'lib/gauge_runtime.rb', line 61

def self.write_message(socket, message)
  serialized_message = message.to_s
  size = serialized_message.bytesize
  ProtocolBuffers::Varint.encode(socket, size)
  socket.write serialized_message
end