Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Fixup mapper to have non nanite identity, use fanout exchange for res…

…ponses

to Request objects in the mapper and not direct queue name
  • Loading branch information...
commit b082a878c203e139bd78e2bfc596a7cd2d33ec70 1 parent 9da8c6a
Ezra Zygmuntowicz authored
View
2  lib/nanite.rb
@@ -30,7 +30,7 @@ def initialize mq, type, name, opts = {}
@key = opts[:key]
@mq.callback{
- @mq.send Protocol::Exchange::Declare.new({ :exchange => name,
+ @mq.send AMQP::Protocol::Exchange::Declare.new({ :exchange => name,
:type => type,
:nowait => true }.merge(opts))
} unless name == "amq.#{type}" or name == '' or opts[:no_declare]
View
2  lib/nanite/agent.rb
@@ -91,7 +91,7 @@ def initialize(options = {})
@log = opts[:log]
@log_dir = opts[:log_dir]
@format = opts[:format] || :marshal
- @identity = "nanite-#{opts[:identity] || Nanite.gensym}"
+ @identity = "#{opts[:mapper] ? 'mapper' : 'nanite'}-#{opts[:identity] || Nanite.gensym}"
@host = opts[:host] || '0.0.0.0'
@vhost = opts[:vhost]
@file_root = opts[:file_root] || "#{root}/files"
View
2  lib/nanite/dispatcher.rb
@@ -65,7 +65,7 @@ def handle(packet)
when Request
agent.log.debug "handling Request: #{packet}"
result = dispatch_request(packet)
- agent.amq.queue(packet.reply_to).publish(agent.dump_packet(result)) if packet.reply_to
+ agent.amq.fanout(packet.reply_to, :no_declare => true).publish(agent.dump_packet(result)) if packet.reply_to
when Result
agent.log.debug "handling Result: #{packet}"
agent.reducer.handle_result(packet)
View
2  lib/nanite/mapper.rb
@@ -199,7 +199,7 @@ def setup_queues
agent.log.debug "Got registration"
register(agent.load_packet(msg))
}
- amq.queue(agent.identity, :exclusive => true).subscribe{ |msg|
+ amq.queue(agent.identity, :exclusive => true).bind(amq.fanout(agent.identity)).subscribe{ |msg|
msg = agent.load_packet(msg)
agent.log.debug "Got a message: #{msg.inspect}"
agent.reducer.handle_result(msg)

0 comments on commit b082a87

Please sign in to comment.
Something went wrong with that request. Please try again.