Class: Nanite::Request

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

Overview

packet that means a work request from mapper to actor node

type is a service name payload is arbitrary data that is transferred from mapper to actor

Options: from is sender identity token is a generated request id that mapper uses to identify replies reply_to is identity of the node actor replies to, usually a mapper itself selector is the selector used to route the request target is the target nanite for the request persistent signifies if this request should be saved to persistent storage by the AMQP broker

Constant Summary collapse

DEFAULT_OPTIONS =
{:selector => :least_loaded}

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from Packet

#to_json

Constructor Details

#initialize(type, payload, opts = {}) ⇒ Request

Returns a new instance of Request.



76
77
78
79
80
81
82
83
84
85
86
# File 'lib/nanite/packets.rb', line 76

def initialize(type, payload, opts={})
  opts = DEFAULT_OPTIONS.merge(opts)
  @type             = type
  @payload          = payload
  @from             = opts[:from]
  @token            = opts[:token]
  @reply_to         = opts[:reply_to]
  @selector         = opts[:selector]
  @target           = opts[:target]
  @persistent       = opts[:persistent]
end

Instance Attribute Details

#fromObject

Returns the value of attribute from.



74
75
76
# File 'lib/nanite/packets.rb', line 74

def from
  @from
end

#payloadObject

Returns the value of attribute payload.



74
75
76
# File 'lib/nanite/packets.rb', line 74

def payload
  @payload
end

#persistentObject

Returns the value of attribute persistent.



74
75
76
# File 'lib/nanite/packets.rb', line 74

def persistent
  @persistent
end

#reply_toObject

Returns the value of attribute reply_to.



74
75
76
# File 'lib/nanite/packets.rb', line 74

def reply_to
  @reply_to
end

#selectorObject

Returns the value of attribute selector.



74
75
76
# File 'lib/nanite/packets.rb', line 74

def selector
  @selector
end

#targetObject

Returns the value of attribute target.



74
75
76
# File 'lib/nanite/packets.rb', line 74

def target
  @target
end

#tokenObject

Returns the value of attribute token.



74
75
76
# File 'lib/nanite/packets.rb', line 74

def token
  @token
end

#typeObject

Returns the value of attribute type.



74
75
76
# File 'lib/nanite/packets.rb', line 74

def type
  @type
end

Class Method Details

.json_create(o) ⇒ Object



87
88
89
90
91
# File 'lib/nanite/packets.rb', line 87

def self.json_create(o)
  i = o['data']
  new(i['type'], i['payload'], {:from => i['from'], :token => i['token'], :reply_to => i['reply_to'], :selector => i['selector'],
    :target => i['target'], :persistent => i['persistent']})
end