Class: Proc::Http::Client
- Inherits:
-
Object
- Object
- Proc::Http::Client
- Defined in:
- lib/proc/http/client.rb
Instance Method Summary collapse
- #call(method, uri, params: {}, headers: {}, body: nil, task: nil) ⇒ Object
- #close ⇒ Object
- #count ⇒ Object
-
#initialize ⇒ Client
constructor
A new instance of Client.
Constructor Details
#initialize ⇒ Client
Returns a new instance of Client.
16 17 18 19 |
# File 'lib/proc/http/client.rb', line 16 def initialize @internet = Async::HTTP::Internet.new @responses = {} end |
Instance Method Details
#call(method, uri, params: {}, headers: {}, body: nil, task: nil) ⇒ Object
21 22 23 24 25 26 27 28 29 30 31 |
# File 'lib/proc/http/client.rb', line 21 def call(method, uri, params: {}, headers: {}, body: nil, task: nil) request = Request.new(method: method, uri: uri, params: params, headers: headers, body: body) if task make_request(request) else Async(logger: NullLogger) { make_request(request) }.wait end end |
#close ⇒ Object
33 34 35 36 37 38 39 |
# File 'lib/proc/http/client.rb', line 33 def close # TODO: Make sure this works. We should also close / clear after accumulating some amount. # @responses.each_value(&:close) @responses.clear @internet.close end |
#count ⇒ Object
41 42 43 |
# File 'lib/proc/http/client.rb', line 41 def count @responses.count end |