Skip to content

Add Finch.start_link spec and Finch.pool_opt,pool_opts types - #382

Open
wojtekmach wants to merge 1 commit into
sneako:mainfrom
wojtekmach:wm-pool-opt
Open

Add Finch.start_link spec and Finch.pool_opt,pool_opts types#382
wojtekmach wants to merge 1 commit into
sneako:mainfrom
wojtekmach:wm-pool-opt

Conversation

@wojtekmach

@wojtekmach wojtekmach commented Jun 19, 2026

Copy link
Copy Markdown
Contributor

In Req I'm adding Req.request(url, finch: opts) where opts are a combination of Finch.build, Finch.request, and Finch.start_link options, see wojtekmach/req#542 (comment).

I'd like to mention pool options by name in the docs because they can't be all mixed and matched (pool options cannot be given when using a named pool).

I think this is the type of single list of options that's then distributed to the three buckets:

[{:name, Finch.name()} | Finch.request_opt() | Finch.Request.build_opt()] |
  [Finch.pool_opt() | Finch.request_opt() | Finch.Request.build_opt()]

(I'm actually not sure if I'm gonna use above type in my docs because it's pretty complicated and so not sure if that useful.)

@wojtekmach

Copy link
Copy Markdown
Contributor Author

As an aside, and I vaguely remember this was maybe brought up already?, here's an idea:

  1. Add %Finch.Request{opts: []} field
  2. Unify Finch.request_opt and Finch.Request.build_opt into just Finch.request_opt

This way, in Finch.request, Keyword.validate!(opts, allowed) would no longer necessarily be in the hot path so to speak (cc @sabiwara), if users pass all the options to Finch.build, what is a left is a no-op Keyword.validate!([], allowed).

And yeah, my type above could become:

[{:name, Finch.name()} | Finch.request_opt()] |
  [{Finch.pool_opt() | Finch.request_opt()}]

That said, it's rather rare for structs to carry options so this needs consideration!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant