Sha256: cd07d6aa2efa828da0b6cd0a4a5642e0943d2bec7d10198422c3d4d9f143c35d
Contents?: true
Size: 1.41 KB
Versions: 3
Compression:
Stored size: 1.41 KB
Contents
# TODO should prolly have the option of using # non auto-delete queues. This would be useful # for logger. Maybe if a peeper name is given, # then create queues with options. class Peeper include Callback attr_reader :server_name def initialize(server_name,callback) @server_name = server_name @clients = {} @callback = build_callback(callback) uid = "#{@server_name}.peeper.#{rand 999_999_999_999}" q = MQ.queue uid, :auto_delete => true q.bind(@server_name) # messages to the server would be duplicated here. q.subscribe { |info,payload| payload = ::Marshal.load(payload) # sets context, but doesn't make the call obj = prepare_callback(@callback,info,payload) # there is a specific method we want to call. obj.server(payload[:method],payload[:data]) # bind to peep client message queue if we've not seen it before. unless @clients.has_key? info.routing_key @clients[info.routing_key] = true client_q = MQ.queue "#{uid}--#{info.routing_key}", :auto_delete => true # messages to the client would be duplicated here. client_q.bind("#{server_name}--", :routing_key => info.routing_key) client_q.subscribe { |info,payload| payload = ::Marshal.load(payload) obj = prepare_callback(@callback,info,payload) obj.client(payload[:method],payload[:data]) } end } end end
Version data entries
3 entries across 3 versions & 3 rubygems
Version | Path |
---|---|
donkey-0.1.0 | lib/ass/peeper.rb |
ASS-0.1.0 | lib/ass/peeper.rb |
jamesgolick-ASS-0.1.0 | lib/ass/peeper.rb |