Open
Conversation
syeopite
commented
Nov 12, 2024
Member
Author
SamantazFox
reviewed
Nov 14, 2024
src/invidious/config.cr
Outdated
| property idle_pool_size : Int32? = nil | ||
|
|
||
| # Amount of seconds to wait for a client to be free from the pool before rasing an error | ||
| property pool_checkout_timeout : Int32 = 5 |
Member
There was a problem hiding this comment.
Oddly, the Crystal compiler didn't complain: there is a type mismatch between this property (Int32) and Pool.timeout (Float64).
Member
Author
There was a problem hiding this comment.
Oops I didn't notice that
But I think that's an intended feature of Crystal. The compiler allows you to use an integer in place of a float but not the other way around.
syeopite
commented
Dec 17, 2024
SamantazFox
requested changes
Apr 6, 2025
- Remove duplication between standard and companion pool - Raises a wrapped exception on any DB:Error - Don't use a non-pool client when client fails - Ensure that client is always released - Add documentation to various pool methods
pool.checkout(&block) already ensures that the checked out item will be released back into the pool
The streaming API of HTTP::Client has an internal buffer that will continue to persist onto the next request unless the response is fully read. This commit privatizes the #client method of Pool and instead expose various HTTP request methods that will call and yield the underlying request and response. This way, we can ensure that the resposne is fully read before the client is passed back into the pool for another request.
@pool.release should not be called when the client has already been deleted from the pool.
Make non-block request method internally call the block based request method.
Defaulting to the streaming api of `HTTP::Client` causes some issues since the streaming respone content needs to be accessed through #body_io rather than #body
Clients created when idle_capacity is reached but not max_capacity are discarded as soon as the client is checked back into the pool, not when the connection is closed. This means that allowing idle_capacity to be lower than max_capacity essentially just makes the remaining clients a checkout timeout deterrent that gets thrown away as soon as it is used. Not useful for reusing connections whatsoever during peak load times
bdcd9af to
0865bc5
Compare
syeopite
commented
Apr 10, 2025
| ## before raising an error | ||
| ## | ||
| ## | ||
| ## Accepted values: a positive integer |
Member
Author
There was a problem hiding this comment.
Suggested change
| ## Accepted values: a positive integer | |
| ## Accepted values: a positive floating point number |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Brings improvements from https://github.com/jgaskins/http_client which is a shard that implements a HTTP connection pool through
DB::Poollike Invidious.The most noticeable change is that connection timeout errors will no longer say
DB::PoolTimeoutbut ratherInvidious::ConnectionPool::Error. Full backtrace here.Backtrace
I've also added a configuration option to customize max idle pool size and the checkout timeout