Class: Nanite::Push
Overview
packet that means a work push 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 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.
-
#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) ⇒ Push
constructor
A new instance of Push.
- #to_s(filter = nil) ⇒ Object
Methods inherited from Packet
Constructor Details
#initialize(type, payload, opts = {}, size = nil) ⇒ Push
Returns a new instance of Push.
184 185 186 187 188 189 190 191 192 193 194 195 196 |
# File 'lib/nanite/packets.rb', line 184 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] @selector = opts[:selector] @target = opts[:target] @persistent = opts[:persistent] @tags = opts[:tags] || [] end |
Instance Attribute Details
#from ⇒ Object
Returns the value of attribute from.
180 181 182 |
# File 'lib/nanite/packets.rb', line 180 def from @from end |
#payload ⇒ Object
Returns the value of attribute payload.
180 181 182 |
# File 'lib/nanite/packets.rb', line 180 def payload @payload end |
#persistent ⇒ Object
Returns the value of attribute persistent.
180 181 182 |
# File 'lib/nanite/packets.rb', line 180 def persistent @persistent end |
#scope ⇒ Object
Returns the value of attribute scope.
180 181 182 |
# File 'lib/nanite/packets.rb', line 180 def scope @scope end |
#selector ⇒ Object
Returns the value of attribute selector.
180 181 182 |
# File 'lib/nanite/packets.rb', line 180 def selector @selector end |
#tags ⇒ Object
Returns the value of attribute tags.
180 181 182 |
# File 'lib/nanite/packets.rb', line 180 def @tags end |
#target ⇒ Object
Returns the value of attribute target.
180 181 182 |
# File 'lib/nanite/packets.rb', line 180 def target @target end |
#token ⇒ Object
Returns the value of attribute token.
180 181 182 |
# File 'lib/nanite/packets.rb', line 180 def token @token end |
#type ⇒ Object
Returns the value of attribute type.
180 181 182 |
# File 'lib/nanite/packets.rb', line 180 def type @type end |
Class Method Details
.json_create(o) ⇒ Object
198 199 200 201 202 203 204 205 |
# File 'lib/nanite/packets.rb', line 198 def self.json_create(o) i = o['data'] new(i['type'], i['payload'], { :from => i['from'], :scope => i['scope'], :token => i['token'], :selector => i['selector'], :target => i['target'], :persistent => i['persistent'], :tags => i['tags'] }, o['size']) end |
Instance Method Details
#to_s(filter = nil) ⇒ Object
207 208 209 210 211 212 213 214 215 |
# File 'lib/nanite/packets.rb', line 207 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 += ", target #{id_to_s(target)}" if target && (filter.nil? || filter.include?(:target)) 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 |