Class: LinkChecker::Async::HTTP::Checker
- Extended by:
- Config
- Defined in:
- lib/ruby-link-checker/async/http/checker.rb
Constant Summary
Constants included from Config
LinkChecker::Async::HTTP::Config::ATTRIBUTES
Constants included from Config
Instance Attribute Summary
Attributes inherited from Checker
Instance Method Summary collapse
-
#_client_for(uri) ⇒ Object
Returns a client for the given URI's host/port/scheme, reusing (and pooling connections on) one client per endpoint across all checks.
- #_queue(&block) ⇒ Object
-
#initialize(options = {}) ⇒ Checker
constructor
A new instance of Checker.
-
#run ⇒ Object
Runs all queued checks concurrently and blocks until they complete.
Methods included from Config
Methods inherited from Checker
Methods included from Callbacks
#callbacks, #delegates, #method_missing, #on
Methods included from Config
Constructor Details
#initialize(options = {}) ⇒ Checker
Returns a new instance of Checker.
39 40 41 42 43 44 45 46 |
# File 'lib/ruby-link-checker/async/http/checker.rb', line 39 def initialize( = {}) LinkChecker::Async::HTTP::Config::ATTRIBUTES.each do |key| send("#{key}=", [key] || LinkChecker::Async::HTTP::Config.send(key)) end @queue = [] @clients = {} super end |
Dynamic Method Handling
This class handles dynamic methods through the method_missing method in the class LinkChecker::Callbacks
Instance Method Details
#_client_for(uri) ⇒ Object
Returns a client for the given URI's host/port/scheme, reusing (and pooling connections on) one client per endpoint across all checks.
69 70 71 72 73 74 75 |
# File 'lib/ruby-link-checker/async/http/checker.rb', line 69 def _client_for(uri) key = [uri.scheme, uri.host, uri.port] @clients[key] ||= begin endpoint = ::Async::HTTP::Endpoint.parse(uri.to_s, timeout: open_timeout) ::Async::HTTP::Client.new(endpoint) end end |
#_queue(&block) ⇒ Object
59 60 61 62 63 64 65 |
# File 'lib/ruby-link-checker/async/http/checker.rb', line 59 def _queue(&block) if @barrier @barrier.async(&block) else @queue << block end end |
#run ⇒ Object
Runs all queued checks concurrently and blocks until they complete.
49 50 51 52 53 54 55 56 57 |
# File 'lib/ruby-link-checker/async/http/checker.rb', line 49 def run Barrier do || @barrier = _flush! end ensure @barrier = nil _close_clients! end |