Skip to content

Commit

Permalink
Default to PerThreadPersistentClients.
Browse files Browse the repository at this point in the history
  • Loading branch information
ioquatix committed Aug 13, 2024
1 parent 31e4e2a commit 90b61ef
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 1 deletion.
2 changes: 1 addition & 1 deletion lib/async/http/faraday/adapter.rb
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ def initialize(...)
if clients = @connection_options.delete(:clients)
@clients = clients.call(**@connection_options, &@config_block)
else
@clients = PersistentClients.new(**@connection_options, &@config_block)
@clients = PerThreadPersistentClients.new(**@connection_options, &@config_block)
end
end

Expand Down
19 changes: 19 additions & 0 deletions test/async/http/faraday/adapter.rb
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,25 @@ def get_response(url = bound_url, path = '/index', adapter_options: {})
it "client can get resource" do
expect(get_response.body).to be == 'Hello World'
end

it "can make several requests on several threads" do
connection = Faraday.new(bound_url) do |builder|
builder.adapter :async_http
end

threads = []

10.times do
threads << Thread.new do
10.times do
response = connection.get("/index")
expect(response).to be(:success?)
end
end
end

threads.each(&:join)
end
end

with "utf-8 response body" do
Expand Down

0 comments on commit 90b61ef

Please sign in to comment.