class Mmtrix::Agent::MmtrixService::Marshaller

Public Class Methods

human_readable?() click to toggle source
# File lib/mmtrix/agent/mmtrix_service/marshaller.rb, line 42
def self.human_readable?
  false
end

Public Instance Methods

default_encoder() click to toggle source
# File lib/mmtrix/agent/mmtrix_service/marshaller.rb, line 38
def default_encoder
  Encoders::Identity
end
parsed_error(error) click to toggle source
# File lib/mmtrix/agent/mmtrix_service/marshaller.rb, line 9
def parsed_error(error)
  error_type    = error['error_type']
  error_message = error['message']

  exception = case error_type
  when 'Mmtrix::Agent::LicenseException'
    LicenseException.new(error_message)
  when 'Mmtrix::Agent::ForceRestartException'
    ForceRestartException.new(error_message)
  when 'Mmtrix::Agent::ForceDisconnectException'
    ForceDisconnectException.new(error_message)
  else
    CollectorError.new("#{error['error_type']}: #{error['message']}")
  end

  exception
end
prepare(data, options={}) click to toggle source
# File lib/mmtrix/agent/mmtrix_service/marshaller.rb, line 27
def prepare(data, options={})
  encoder = options[:encoder] || default_encoder
  if data.respond_to?(:to_collector_array)
    data.to_collector_array(encoder)
  elsif data.kind_of?(Array)
    data.map { |element| prepare(element, options) }
  else
    data
  end
end

Protected Instance Methods

return_value(data) click to toggle source
# File lib/mmtrix/agent/mmtrix_service/marshaller.rb, line 48
def return_value(data)
  if data.respond_to?(:has_key?)
    if data.has_key?('exception')
      raise parsed_error(data['exception'])
    elsif data.has_key?('return_value')
      return data['return_value']
    end
  end
  ::Mmtrix::Agent.logger.debug("Unexpected response from collector: #{data}")
  nil
end