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



641
642
643
644
645
646
# File 'lib/right_agent/packets.rb', line 641

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.



631
632
633
# File 'lib/right_agent/packets.rb', line 631

def data
  @data
end

#fromObject

Returns the value of attribute from.



631
632
633
# File 'lib/right_agent/packets.rb', line 631

def from
  @from
end

#tokenObject

Returns the value of attribute token.



631
632
633
# File 'lib/right_agent/packets.rb', line 631

def token
  @token
end

Class Method Details

.create(o) ⇒ Object

Create packet from unmarshalled data

Parameters

o(Hash)

Unmarshalled data

Return

(Result)

New packet



655
656
657
658
# File 'lib/right_agent/packets.rb', line 655

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



668
669
670
# File 'lib/right_agent/packets.rb', line 668

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