feat: introduce pluggable HTTP client behaviour#150
Open
klacointe wants to merge 1 commit into
Open
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
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