Class: Nanite::Register

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

Overview

packet that means an availability notification sent from actor to mapper

from is sender identity services is a list of services provided by the node status is a load of the node by default, but may be any criteria

agent may use to report it's availability, load, etc

Instance Attribute Summary collapse

Attributes inherited from Packet

#size

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from Packet

#id_to_s, #to_json

Constructor Details

#initialize(identity, services, status, tags, size = nil) ⇒ Register

Returns a new instance of Register.



281
282
283
284
285
286
287
# File 'lib/nanite/packets.rb', line 281

def initialize(identity, services, status, tags, size=nil)
  @status   = status
  @tags     = tags
  @identity = identity
  @services = services
  @size     = size
end

Instance Attribute Details

#identityObject

Returns the value of attribute identity.



279
280
281
# File 'lib/nanite/packets.rb', line 279

def identity
  @identity
end

#servicesObject

Returns the value of attribute services.



279
280
281
# File 'lib/nanite/packets.rb', line 279

def services
  @services
end

#statusObject

Returns the value of attribute status.



279
280
281
# File 'lib/nanite/packets.rb', line 279

def status
  @status
end

#tagsObject

Returns the value of attribute tags.



279
280
281
# File 'lib/nanite/packets.rb', line 279

def tags
  @tags
end

Class Method Details

.json_create(o) ⇒ Object



289
290
291
292
# File 'lib/nanite/packets.rb', line 289

def self.json_create(o)
  i = o['data']
  new(i['identity'], i['services'], i['status'], i['tags'], o['size'])
end

Instance Method Details

#to_sObject



294
295
296
297
298
299
# File 'lib/nanite/packets.rb', line 294

def to_s
  log_msg = "#{super} #{id_to_s(identity)}"
  log_msg += ", services: #{services.join(', ')}" if services && !services.empty?
  log_msg += ", tags: #{tags.join(', ')}" if tags && !tags.empty?
  log_msg
end