Skip to content

Commit 90b61ef

Browse files
committed
Default to PerThreadPersistentClients.
1 parent 31e4e2a commit 90b61ef

File tree

2 files changed

+20
-1
lines changed

2 files changed

+20
-1
lines changed

lib/async/http/faraday/adapter.rb

+1-1
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,7 @@ def initialize(...)
7676
if clients = @connection_options.delete(:clients)
7777
@clients = clients.call(**@connection_options, &@config_block)
7878
else
79-
@clients = PersistentClients.new(**@connection_options, &@config_block)
79+
@clients = PerThreadPersistentClients.new(**@connection_options, &@config_block)
8080
end
8181
end
8282

test/async/http/faraday/adapter.rb

+19
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,25 @@ def get_response(url = bound_url, path = '/index', adapter_options: {})
4343
it "client can get resource" do
4444
expect(get_response.body).to be == 'Hello World'
4545
end
46+
47+
it "can make several requests on several threads" do
48+
connection = Faraday.new(bound_url) do |builder|
49+
builder.adapter :async_http
50+
end
51+
52+
threads = []
53+
54+
10.times do
55+
threads << Thread.new do
56+
10.times do
57+
response = connection.get("/index")
58+
expect(response).to be(:success?)
59+
end
60+
end
61+
end
62+
63+
threads.each(&:join)
64+
end
4665
end
4766

4867
with "utf-8 response body" do

0 commit comments

Comments
 (0)