Class: Nanite::Request
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 scope define behavior that should be used to resolve tag based routing 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
-
#from ⇒ Object
Returns the value of attribute from.
-
#payload ⇒ Object
Returns the value of attribute payload.
-
#persistent ⇒ Object
Returns the value of attribute persistent.
-
#reply_to ⇒ Object
Returns the value of attribute reply_to.
-
#scope ⇒ Object
Returns the value of attribute scope.
-
#selector ⇒ Object
Returns the value of attribute selector.
-
#tags ⇒ Object
Returns the value of attribute tags.
-
#target ⇒ Object
Returns the value of attribute target.
-
#token ⇒ Object
Returns the value of attribute token.
-
#type ⇒ Object
Returns the value of attribute type.
Attributes inherited from Packet
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(type, payload, opts = {}, size = nil) ⇒ Request
constructor
A new instance of Request.
- #to_s(filter = nil) ⇒ Object
Methods inherited from Packet
Constructor Details
#initialize(type, payload, opts = {}, size = nil) ⇒ Request
Returns a new instance of Request.
128 129 130 131 132 133 134 135 136 137 138 139 140 141 |
# File 'lib/nanite/packets.rb', line 128 def initialize(type, payload, opts={}, size=nil) opts = DEFAULT_OPTIONS.merge(opts) @type = type @payload = payload @size = size @from = opts[:from] @scope = opts[:scope] @token = opts[:token] @reply_to = opts[:reply_to] @selector = opts[:selector] @target = opts[:target] @persistent = opts[:persistent] @tags = opts[:tags] || [] end |
Instance Attribute Details
#from ⇒ Object
Returns the value of attribute from.
124 125 126 |
# File 'lib/nanite/packets.rb', line 124 def from @from end |
#payload ⇒ Object
Returns the value of attribute payload.
124 125 126 |
# File 'lib/nanite/packets.rb', line 124 def payload @payload end |
#persistent ⇒ Object
Returns the value of attribute persistent.
124 125 126 |
# File 'lib/nanite/packets.rb', line 124 def persistent @persistent end |
#reply_to ⇒ Object
Returns the value of attribute reply_to.
124 125 126 |
# File 'lib/nanite/packets.rb', line 124 def reply_to @reply_to end |
#scope ⇒ Object
Returns the value of attribute scope.
124 125 126 |
# File 'lib/nanite/packets.rb', line 124 def scope @scope end |
#selector ⇒ Object
Returns the value of attribute selector.
124 125 126 |
# File 'lib/nanite/packets.rb', line 124 def selector @selector end |
#tags ⇒ Object
Returns the value of attribute tags.
124 125 126 |
# File 'lib/nanite/packets.rb', line 124 def @tags end |
#target ⇒ Object
Returns the value of attribute target.
124 125 126 |
# File 'lib/nanite/packets.rb', line 124 def target @target end |
#token ⇒ Object
Returns the value of attribute token.
124 125 126 |
# File 'lib/nanite/packets.rb', line 124 def token @token end |
#type ⇒ Object
Returns the value of attribute type.
124 125 126 |
# File 'lib/nanite/packets.rb', line 124 def type @type end |
Class Method Details
.json_create(o) ⇒ Object
143 144 145 146 147 148 149 150 |
# File 'lib/nanite/packets.rb', line 143 def self.json_create(o) i = o['data'] new(i['type'], i['payload'], { :from => i['from'], :scope => i['scope'], :token => i['token'], :reply_to => i['reply_to'], :selector => i['selector'], :target => i['target'], :persistent => i['persistent'], :tags => i['tags'] }, o['size']) end |
Instance Method Details
#to_s(filter = nil) ⇒ Object
152 153 154 155 156 157 158 159 160 161 |
# File 'lib/nanite/packets.rb', line 152 def to_s(filter=nil) log_msg = "#{super} <#{token}> #{type}" log_msg += " from #{id_to_s(from)}" if filter.nil? || filter.include?(:from) log_msg += " with scope #{scope}" if scope && (filter.nil? || filter.include?(:scope)) log_msg += " to #{id_to_s(target)}" if target && (filter.nil? || filter.include?(:target)) log_msg += ", reply_to #{id_to_s(reply_to)}" if reply_to && (filter.nil? || filter.include?(:reply_to)) log_msg += ", tags #{.inspect}" if && !.empty? && (filter.nil? || filter.include?(:tags)) log_msg += ", payload #{payload.inspect}" if filter.nil? || filter.include?(:payload) log_msg end |