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.

File.join(Dir.pwd, 'step_implementations')

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.



32
33
34
35
36
37
38
39
40
41
42
43
# File 'lib/gauge_runtime.rb', line 32

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.



46
47
48
49
50
51
52
53
54
55
56
# File 'lib/gauge_runtime.rb', line 46

def self.handle_message(socket, message)
  if (!MessageProcessor.is_valid_message(message))
    puts "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)
  end
end

.portFromEnvVariable(envVariable) ⇒ 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.



65
66
67
68
69
70
71
# File 'lib/gauge_runtime.rb', line 65

def self.portFromEnvVariable(envVariable)
  port = ENV[envVariable]
  if (port.nil?)
    raise RuntimeError, "Could not find Env variable :#{envVariable}"
  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.



58
59
60
61
62
63
# File 'lib/gauge_runtime.rb', line 58

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