feat: introduce pluggable HTTP client behaviour#150
Merged
achempion merged 2 commits intoJul 2, 2026
Merged
Conversation
Contributor
Author
|
@achempion when you'll be ok with this one I'll propose the Finch adapter. |
9c5b76f to
df970da
Compare
- Add Waffle.HTTPClient behaviour with a single get/3 callback - Add Waffle.HTTPClient.Hackney as the default implementation - Refactor Waffle.File to dispatch through the configured :http_client instead of calling hackney directly; retry logic stays client-agnostic - Document how to implement a custom HTTP client adapter
df970da to
e6a6bd6
Compare
achempion
approved these changes
Jun 23, 2026
achempion
left a comment
Member
There was a problem hiding this comment.
looking great, left couple of minor comments before merging
achempion
reviewed
Jun 23, 2026
Contributor
|
I am excited to see this work going into waffle, and I'm happy to help push it forward if needed. |
Contributor
Author
I'm on holidays for the 2 following weeks and will not have time to work on this before 😕 |
klacointe
added a commit
to klacointe/waffle
that referenced
this pull request
Jul 1, 2026
- Share a normalize_error/1 helper between the connect/response error
path and the read_body error path in Waffle.HTTPClient.Hackney, so a
timeout while streaming the response body now normalizes to
{:error, :timeout} / {:error, :recv_timeout} instead of being wrapped
as {:error, {:http_error, reason}}
- This makes body-read timeouts retryable, matching connection timeouts
- Replace assert called(...) with assert_called_exactly(..., 3) in the
retry tests so the asserted call count matches the inline comment
- Add coverage for both timeout error shapes during body read
Addresses review feedback on elixir-waffle#150
- Share a normalize_error/1 helper between the connect/response error
path and the read_body error path in Waffle.HTTPClient.Hackney, so a
timeout while streaming the response body now normalizes to
{:error, :timeout} / {:error, :recv_timeout} instead of being wrapped
as {:error, {:http_error, reason}}
- This makes body-read timeouts retryable, matching connection timeouts
- Inline retry_or_error/5 into request/4's case clause since it was a
5-arg helper used from a single call site
- Replace assert called(...) with assert_called_exactly(..., 3) in the
retry tests so the asserted call count matches the inline comment
- Add coverage for both timeout error shapes during body read
Addresses review feedback on elixir-waffle#150
3f1d66d to
d068c11
Compare
Contributor
Author
I finally found some time. |
Member
|
Looking great, thanks for the PR I'll publish new minor release soon. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Waffle.HTTPClientbehaviour with a singleget/3callbackWaffle.HTTPClient.Hackneyas the default implementation (existing behaviour, just moved into a dedicated module)Waffle.Fileto dispatch through the configured:http_clientinstead of calling hackney directly; retry logic stays client-agnosticUsage
Configure a custom client:
Implement the behaviour:
Error shape changes
{:error, :timeout}{:error, :timeout}— unchanged{:error, :recv_timeout}{:error, :recv_timeout}— unchanged{:error, {:waffle_hackney_error, {:ok, 503, headers, ref}}}{:error, :service_unavailable}{:error, {:waffle_hackney_error, {:ok, status, headers, ref}}}{:error, {:http_error, status}}e.g.{:error, {:http_error, 404}}The previous 503 and non-2xx shapes leaked a closed hackney
client_refinside the error tuple.Notes
#75