Class: ChimeraHttpClient::Queue
- Inherits:
-
Base
- Object
- Base
- ChimeraHttpClient::Queue
show all
- Defined in:
- lib/chimera_http_client/queue.rb
Constant Summary
Constants inherited
from Base
Base::USER_AGENT
Instance Method Summary
collapse
Methods inherited from Base
#initialize
Instance Method Details
#add(method, endpoint, options = {}) ⇒ Object
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
|
# File 'lib/chimera_http_client/queue.rb', line 3
def add(method, endpoint, options = {})
http_method = method.downcase.to_sym
options[:body_optional] = true if %i[get delete].include?(http_method)
body = extract_body(options)
= (options, )
req = Request.new(logger: @logger).create(
url: url(endpoint),
method: http_method,
body: body,
options: augmented_options(options),
headers:
)
queued_requests << req
end
|
#empty ⇒ Object
35
36
37
|
# File 'lib/chimera_http_client/queue.rb', line 35
def empty
@queued_requests = []
end
|
#execute ⇒ Object
21
22
23
24
25
26
27
28
29
30
31
32
33
|
# File 'lib/chimera_http_client/queue.rb', line 21
def execute
queued_requests.each do |request|
hydra.queue(request.request)
end
hydra.run
responses = queued_requests.map { |request| request.result }
empty
responses
end
|
#queued_requests ⇒ Object
39
40
41
|
# File 'lib/chimera_http_client/queue.rb', line 39
def queued_requests
@queued_requests ||= []
end
|