Class: Async::HTTP::Faraday::ParallelManager

Inherits:
Object
  • Object
show all
Defined in:
lib/async/http/faraday/adapter.rb

Overview

Implement the Faraday parallel manager interface, using Async.

Instance Method Summary collapse

Constructor Details

#initialize(options = {}) ⇒ ParallelManager

Create a new parallel manager.



62
63
64
65
# File 'lib/async/http/faraday/adapter.rb', line 62

def initialize(options = {})
	@options = options
	@barrier = nil
end

Instance Method Details

#async(&block) ⇒ Object

Run the given block asynchronously, using the barrier if available.



75
76
77
78
79
80
81
# File 'lib/async/http/faraday/adapter.rb', line 75

def async(&block)
	if @barrier
		@barrier.async(&block)
	else
		Sync(&block)
	end
end

#execute(&block) ⇒ Object

Execute the given block which can perform multiple concurrent requests, waiting for them all to complete.



84
85
86
87
88
89
90
91
92
93
94
# File 'lib/async/http/faraday/adapter.rb', line 84

def execute(&block)
	Sync do
		@barrier = Async::Barrier.new
		
		yield
		
		@barrier.wait
	ensure
		@barrier&.stop
	end
end

#runObject

Deprecated.

Please update your Faraday version!



68
69
70
71
72
# File 'lib/async/http/faraday/adapter.rb', line 68

def run
	if $VERBOSE
		warn "Please update your Faraday version!", uplevel: 2
	end
end