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.



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

def self.dispatch_messages(socket)
  until socket.eof?
    len = Connector.message_length(socket)
    data = socket.read len
    message = Messages::Message.decode(data)
    handle_message(socket, message)
    if message.messageType == :KillProcessRequest || 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: :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
# File 'lib/gauge_runtime.rb', line 68

def self.port_from_env_variable(env_variable)
  port = ENV[env_variable]
  raise "Could not find Env variable :#{env_variable}" if port.nil?
  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 = Messages::Message.encode(message)
  size = serialized_message.bytesize
  ProtocolBuffers::Varint.encode(socket, size)
  socket.write serialized_message
end