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, #wrap

Constructor Details

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

Returns a new instance of Register.



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

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.



284
285
286
# File 'lib/nanite/packets.rb', line 284

def identity
  @identity
end

#servicesObject

Returns the value of attribute services.



284
285
286
# File 'lib/nanite/packets.rb', line 284

def services
  @services
end

#statusObject

Returns the value of attribute status.



284
285
286
# File 'lib/nanite/packets.rb', line 284

def status
  @status
end

#tagsObject

Returns the value of attribute tags.



284
285
286
# File 'lib/nanite/packets.rb', line 284

def tags
  @tags
end

Class Method Details

.json_create(o) ⇒ Object



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

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



299
300
301
302
303
304
# File 'lib/nanite/packets.rb', line 299

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?
  wrap(log_msg)
end