Skip to content

Commit

Permalink
Documentation coverage.
Browse files Browse the repository at this point in the history
  • Loading branch information
ioquatix committed Jan 23, 2025
1 parent 077624a commit eb59b82
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions lib/async/http/faraday/adapter.rb
Original file line number Diff line number Diff line change
Expand Up @@ -50,18 +50,22 @@ def read
end
end

# Implement the Faraday parallel manager interface, using Async.
class ParallelManager
# Create a new parallel manager.
def initialize(options = {})
@options = options
@barrier = nil
end

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

# Run the given block asynchronously, using the barrier if available.
def async(&block)
if @barrier
@barrier.async(&block)
Expand All @@ -70,6 +74,7 @@ def async(&block)
end
end

# Execute the given block which can perform multiple concurrent requests, waiting for them all to complete.
def execute(&block)
Sync do
@barrier = Async::Barrier.new
Expand All @@ -87,6 +92,7 @@ def execute(&block)
class Adapter < ::Faraday::Adapter
self.supports_parallel = true

# Create a new parallel manager, which is used to handle multiple concurrent requests.
def self.setup_parallel_manager(**options)
ParallelManager.new(options)
end
Expand Down

0 comments on commit eb59b82

Please sign in to comment.