Ensure a single Faraday client is used per Client #137
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.
Purpose
This PR ensures a single
FaradayHTTP client is used perTrino::Clientinstance.Overview
For now, each
start,resumeorkillquery would instantiate a newFaradayclient by callingTrino::Client.faraday_clientat the query level.This PR refactors the logic of the
Trino::Clientto ensure a singleFaradayclient is used per instance ofTrino::Clientand set all the query (and user) specific HTTP headers at query time. This avoids the need to reconnect to the Trino server dealing with all the SSL handshake processing time at each query + allow the usage of faraday-net_http_persistent to benefit from HTTP keep-alive.While the benefit of saving a few ms at each Trino statement query might not be that visible for the "long running queries" use-cases (where the actual Trino query anyway takes up to a few seconds to answer), we've seen large improvements for use-cases where the queries are taking a few dozens of ms.
Checklist