Description:
Hi @jaeyson,
I would like to request an enhancement to the ExTypesense.HttpClient
module to allow developers to configure the options
for Req.Request
through the application configuration. This would provide greater flexibility and allow developers to tailor the HTTP client to their specific needs.
For example, it would be beneficial to configure the options
like so:
config :ex_typesense,
api_key: "XXXXXX",
...
options: [finch: MyApp.Finch]
This change would enable developers to leverage the various options available in Req.Request
, such as:
:finch
- the name of the Finch pool.
:connect_options
- dynamically starts (or re-uses already started) Finch pool with the given connection options.
:inet6
- if set to true, uses IPv6.
:pool_timeout
- pool checkout timeout in milliseconds.
:receive_timeout
- socket receive timeout in milliseconds.
:unix_socket
- if set, connect through the given UNIX domain socket.
:finch_private
- a map or keyword list of private metadata to add to the Finch request.
:finch_request
- a function that executes the Finch request.
For more details on the available options, please refer to the Req documentation.
Reason for Request:
The primary reason for this request is to provide developers with the ability to configure the HttpClient
to meet their specific requirements. By exposing the options
for Req.Request
as a configurable value, developers can easily adjust the behavior of the HTTP client without modifying the library code.
Use Case:
One specific use case for this enhancement is the need to use a different Finch adapter other than the default one started by Req. For instance, in a scenario where an application has multiple Finch pools configured for different services, a developer might want to specify a particular Finch pool for the HttpClient
to use. This can be achieved by configuring the options
as follows:
config :ex_typesense,
api_key: "XXXXXX",
...
options: [finch: MyApp.CustomFinch]
In this example, MyApp.CustomFinch
is a custom Finch pool that the developer has configured with specific connection options or other settings that differ from the default Finch pool. This flexibility allows the developer to optimize the HTTP client's performance and behavior according to the application's unique requirements.
Thank you for considering this enhancement. I believe it will greatly improve the flexibility and usability of the ExTypesense
library.