Module: Ecfr::ParallelClient::ClassMethods

Defined in:
lib/ecfr/parallel_client.rb

Instance Method Summary collapse

Instance Method Details

#parallel_client(base_url:, client_options: {}) ⇒ Object



4
5
6
7
8
9
# File 'lib/ecfr/parallel_client.rb', line 4

def parallel_client(base_url:, client_options: {})
  client(
    base_url: base_url,
    client_options: client_options.merge({adapter: :typhoeus})
  )
end

#parallel_get(requests, client) ⇒ Object

currently only handles expected cases when calling -renderer



12
13
14
15
16
17
18
19
20
21
22
# File 'lib/ecfr/parallel_client.rb', line 12

def parallel_get(requests, client)
  client.in_parallel do
    requests.each do |request|
      request.response = client.get(request.path, request.args) do |req|
        Ecfr.config.request_hook.call(req)
      end
    end
  end

  requests
end