Class: RightScale::Stats

Inherits:
Packet show all
Defined in:
lib/right_agent/packets.rb

Overview

Packet for carrying statistics

Constant Summary

Constants inherited from Packet

Packet::DEFAULT_VERSION, Packet::GLOBAL, Packet::NOT_SERIALIZED, Packet::PACKET_SIZE_REGEXP, Packet::VERSION

Instance Attribute Summary collapse

Attributes inherited from Packet

#received_at, #size

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from Packet

compatible, #enough_precision, #id_to_s, #ids_to_s, json_create, msgpack_create, #name, #one_way, #recv_version, #send_version, #send_version=, #target_for_encryption, #to_json, #to_msgpack, #trace

Constructor Details

#initialize(data, from, version = [VERSION, VERSION], size = nil) ⇒ Stats

Create packet

Parameters

data(Object)

Data

from(String)

Identity of sender

version(Array)

Protocol version of the original creator of the packet followed by the

protocol version of the packet contents to be used when sending
size(Integer)

Size of request in bytes used only for marshalling



646
647
648
649
650
651
# File 'lib/right_agent/packets.rb', line 646

def initialize(data, from, version = [VERSION, VERSION], size = nil)
  @data    = data
  @from    = from
  @version = version
  @size    = size
end

Instance Attribute Details

#dataObject

Returns the value of attribute data.



636
637
638
# File 'lib/right_agent/packets.rb', line 636

def data
  @data
end

#fromObject

Returns the value of attribute from.



636
637
638
# File 'lib/right_agent/packets.rb', line 636

def from
  @from
end

#tokenObject

Returns the value of attribute token.



636
637
638
# File 'lib/right_agent/packets.rb', line 636

def token
  @token
end

Class Method Details

.create(o) ⇒ Object

Create packet from unmarshalled data

Parameters

o(Hash)

Unmarshalled data

Return

(Result)

New packet



660
661
662
663
# File 'lib/right_agent/packets.rb', line 660

def self.create(o)
  i = o['data']
  new(i['data'], self.compatible(i['from']), i['version'] || [DEFAULT_VERSION, DEFAULT_VERSION], o['size'])
end

Instance Method Details

#to_s(filter = nil, version = nil) ⇒ Object

Generate log representation

Parameters

filter(Array(Symbol))

Attributes to be included in output

version(Symbol|nil)

Version to display: :recv_version, :send_version, or nil meaning none

Return

log_msg(String)

Log representation



673
674
675
# File 'lib/right_agent/packets.rb', line 673

def to_s(filter = nil, version = nil)
  log_msg = "#{super(filter, version)} #{id_to_s(@from)}"
end