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::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



639
640
641
642
643
644
# File 'lib/right_agent/packets.rb', line 639

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.



629
630
631
# File 'lib/right_agent/packets.rb', line 629

def data
  @data
end

#fromObject

Returns the value of attribute from.



629
630
631
# File 'lib/right_agent/packets.rb', line 629

def from
  @from
end

#tokenObject

Returns the value of attribute token.



629
630
631
# File 'lib/right_agent/packets.rb', line 629

def token
  @token
end

Class Method Details

.create(o) ⇒ Object

Create packet from unmarshalled data

Parameters

o(Hash)

Unmarshalled data

Return

(Result)

New packet



653
654
655
656
# File 'lib/right_agent/packets.rb', line 653

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



666
667
668
# File 'lib/right_agent/packets.rb', line 666

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