Class: Ratr::ParallelHttpProcessor
- Inherits:
-
Object
- Object
- Ratr::ParallelHttpProcessor
- Defined in:
- lib/ratr/parallel_http_processor.rb
Instance Attribute Summary collapse
-
#concurrency ⇒ Object
readonly
Returns the value of attribute concurrency.
-
#http_adapter ⇒ Object
readonly
Returns the value of attribute http_adapter.
Instance Method Summary collapse
-
#initialize(options = {}) ⇒ ParallelHttpProcessor
constructor
A new instance of ParallelHttpProcessor.
- #parallel_manager ⇒ Object
- #process(&block) ⇒ Object
Constructor Details
#initialize(options = {}) ⇒ ParallelHttpProcessor
Returns a new instance of ParallelHttpProcessor.
4 5 6 7 |
# File 'lib/ratr/parallel_http_processor.rb', line 4 def initialize(={}) @concurrency = .fetch(:concurrency, 2) @http_adapter = [:http_adapter] end |
Instance Attribute Details
#concurrency ⇒ Object (readonly)
Returns the value of attribute concurrency.
3 4 5 |
# File 'lib/ratr/parallel_http_processor.rb', line 3 def concurrency @concurrency end |
#http_adapter ⇒ Object (readonly)
Returns the value of attribute http_adapter.
3 4 5 |
# File 'lib/ratr/parallel_http_processor.rb', line 3 def http_adapter @http_adapter end |
Instance Method Details
#parallel_manager ⇒ Object
15 16 17 |
# File 'lib/ratr/parallel_http_processor.rb', line 15 def parallel_manager @parallel_manager ||= Typhoeus::Hydra.new(max_concurrency: concurrency) end |
#process(&block) ⇒ Object
9 10 11 12 13 |
# File 'lib/ratr/parallel_http_processor.rb', line 9 def process(&block) http_adapter.in_parallel(parallel_manager) do block.call end end |