Skip to content

Clarifying adapter usage vs "plain Async" #56

Answered by ioquatix
balvig asked this question in Q&A
Discussion options

You must be logged in to vote

Thanks for the question! Here's how these approaches differ:

1. Using async_http as the Faraday adapter, without an Async block

Faraday.default_adapter = :async_http

response1 = adapter.get("/index")
response2 = adapter.get("/index")

puts response1.body
puts response2.body

Each request happens one after the other, and the adapter sets up its own reactor for every request. This means you’re not getting concurrency or persistent connections. Even though you’re using the async adapter, it’s essentially behaving synchronously.

2. Using async_http inside an Async block

Faraday.default_adapter = :async_http

Async do
  response1 = Async{adapter.get("/index")}
  response2 = Async{adapter.get("…

Replies: 1 comment 1 reply

Comment options

You must be logged in to vote
1 reply
@balvig
Comment options

Answer selected by balvig
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants
Converted from issue

This discussion was converted from issue #55 on June 27, 2025 14:02.