Repository navigation
Conversation
yuokada
left a comment
There was a problem hiding this comment.
Sorry for the late response.
One question: Could you clarify why Basic Auth was moved from Faraday’s middleware to manually generated per-request headers? Was this needed for connection reuse or compatibility with Faraday 1 and 2?
|
Thanks for taking a look! This wasn’t required for connection reuse or Faraday 1/2 compatibility. |
|
Thanks for your explanation. One edge case: if a client is created with HTTP and no password, then a password is added to the options before a query; #168 reuses the HTTP connection but adds the credentials to the Authorization header. On master, each query creates a Faraday connection using the current options. During setup, the client checks that password authentication uses HTTPS before configuring the Basic Auth middleware. In short, master checks the credentials and connection scheme together at query time, while #168 checks the scheme only when the Client is initialized. Could we recheck that the connection is HTTPS before adding Basic Auth to each query? |
|
Thanks for pointing this out. I propose keeping connection settings fixed for the lifetime of the client, with a new client required to change them. Query-specific headers, including Basic Auth, would still use the options at query start. |
|
Thanks for the review and approval, @yuokada! |
|
I need a bit of time to check the impact on our internal repos. I'll follow up here once I finish checking. |
Purpose
Reuse a single Faraday HTTP client for each
Trino::Clientinstance.Currently, query operations create a new Faraday client for each request.
Reusing the client reduces connection and TLS handshake overhead and enables HTTP keep-alive with a compatible Faraday adapter.
This PR is based on the idea and implementation proposed in #137. Since that PR has not been updated for over a year, this PR provides a fresh implementation for the current codebase with expanded test coverage.
Thank you to @redox for the original proposal and implementation.
Overview
Trino::ClientinstanceChecklist