Add Finch HTTP client and make hackney an optional dependency#151
Add Finch HTTP client and make hackney an optional dependency#151klacointe wants to merge 1 commit into
Conversation
1af66b8 to
8b3cc7a
Compare
- Add Waffle.HTTPClient.Finch, ported from the closed elixir-waffle#148 (already survived two rounds of review there), guarded with Code.ensure_loaded?(Finch) so it compiles out when finch isn't a dep - Make :hackney optional: true; guard Waffle.HTTPClient.Hackney with Code.ensure_loaded?(:hackney) and raise a clear, actionable error if it's the (default) configured client but the dependency is missing - Extract parse_content_disposition/1 onto the Waffle.HTTPClient behaviour so both clients (and custom implementations) share one parser instead of Hackney depending on the internal :hackney_headers module - Bump CI's Dockerfile to elixir:1.17-alpine (finch requires ~> 1.15) - Bump credo to ~> 1.7; ~> 1.4's tokenizer crashes under Elixir 1.17+ - Add @moduledoc false to Mix.Tasks.Waffle; credo 1.7 newly flags it as missing, unlike 1.6 - Update README/CHANGELOG to document both clients and the "at least one is required" dependency story
8b3cc7a to
58a4d41
Compare
|
Would be great to have this, as waffle is now blocking us from updating hackney |
|
I don't think it's safe to merge this in its current shape. If someone wants to have another stub on this, PR is welcome. p.s. Since PR is generated by LLM and ignores contribution policy, I'll post a short codereview summary generated LLM.
|
Thanks for the review 🙏 |
Summary
Follow-up to #149, #150. Revives the Finch client from the closed #148 (which was split up to keep that PR scoped to the adapter pattern), and completes the original goal: making
:hackneyan optional dependency now that a real alternative exists.Waffle.HTTPClient.Finch, guarded withCode.ensure_loaded?(Finch)— the implementation is carried over unchanged from Add pluggable HTTP client behaviour with Hackney and Finch implementations #148.:hackneyoptional: true. Since it remains the default configured client,Waffle.HTTPClient.Hackneyis still always defined, but guarded withCode.ensure_loaded?(:hackney); if it's missing, calling it raises a clear, actionable error instead of a bareUndefinedFunctionError.parse_content_disposition/1onto theWaffle.HTTPClientbehaviour so both clients (and any custom implementation) share one parser, instead ofHackneydepending on the internal:hackney_headersmodule.Dockerfiletoelixir:1.17-alpine(Finch requires Elixir~> 1.15).Configuration
Notes
:http_client, so a bareUndefinedFunctionErrornaming the module you just typed is already self-diagnosing.Tests
Waffle.HTTPClient.Finch(mocked transport layer, redirects, body-size limiting, timeouts)parse_content_disposition/1helperstore_test.exstest that relied on hackney's internal header-parsing API