Class: Requeus::Impl
Instance Method Summary collapse
- #blob_sequence ⇒ Object
- #config ⇒ Object
- #config_path=(path) ⇒ Object
- #queues ⇒ Object
- #request(queue, method, path, params, headers, force_endpoint) ⇒ Object
- #server_sequence ⇒ Object
- #start_workers ⇒ Object
Instance Method Details
#blob_sequence ⇒ Object
39 40 41 42 43 44 |
# File 'lib/requeus/impl.rb', line 39 def blob_sequence @blob_sequence ||= config['blob']['sequence'].split.map do |name| conf = @config['blob'][name] Requeus::BlobStore.new name, conf end end |
#config ⇒ Object
20 21 22 |
# File 'lib/requeus/impl.rb', line 20 def config @config ||= YAML.load_file(@config_path)[ENV['REQUEUS_ENV'] || ENV['RAILS_ENV'] || 'development'] end |
#config_path=(path) ⇒ Object
16 17 18 |
# File 'lib/requeus/impl.rb', line 16 def config_path= path @config_path = path end |
#queues ⇒ Object
24 25 26 27 28 29 30 |
# File 'lib/requeus/impl.rb', line 24 def queues @queues ||= {}.tap do |queues| config['queues'].each do |name, conf| queues[name] = Requeus::Queue.new conf end end end |
#request(queue, method, path, params, headers, force_endpoint) ⇒ Object
7 8 9 10 |
# File 'lib/requeus/impl.rb', line 7 def request queue, method, path, params, headers, force_endpoint r = Requeus::Request.new(method, path, params, headers, force_endpoint).to_json server_sequence.any? {|q| q.put(queues[queue].name, r)} end |
#server_sequence ⇒ Object
32 33 34 35 36 37 |
# File 'lib/requeus/impl.rb', line 32 def server_sequence @server_sequence ||= config['servers']['sequence'].split.map do |name| conf = @config['servers'][name] Requeus::Server.new name, conf end end |
#start_workers ⇒ Object
12 13 14 |
# File 'lib/requeus/impl.rb', line 12 def start_workers queues.values.map {|q| q.start_workers}.flatten.each(&:join) end |