From 0322d764a5f918b6d45f12133bbb0b5c3fa6ca1d Mon Sep 17 00:00:00 2001 From: Andrew Zhao Date: Sat, 10 Apr 2021 09:31:04 -0700 Subject: [PATCH 1/2] remove pool --- src/invidious/helpers/utils.cr | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/invidious/helpers/utils.cr b/src/invidious/helpers/utils.cr index 67f496dfb1..ec68244c58 100644 --- a/src/invidious/helpers/utils.cr +++ b/src/invidious/helpers/utils.cr @@ -1,5 +1,5 @@ require "lsquic" -require "pool/connection" +require "db" def add_yt_headers(request) request.headers["user-agent"] ||= "Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/78.0.3904.97 Safari/537.36" @@ -20,7 +20,7 @@ struct QUICPool property! url : URI property! capacity : Int32 property! timeout : Float64 - property pool : ConnectionPool(QUIC::Client) + property pool : DB::Pool(QUIC::Client) def initialize(url : URI, @capacity = 5, @timeout = 5.0) @url = url @@ -43,7 +43,7 @@ struct QUICPool conn.before_request { |r| add_yt_headers(r) } if url.host == "www.youtube.com" response = yield conn ensure - pool.checkin(conn) + pool.release(conn) end end @@ -51,7 +51,7 @@ struct QUICPool end private def build_pool - ConnectionPool(QUIC::Client).new(capacity: capacity, timeout: timeout) do + DB::Pool(QUIC::Client).new(initial_pool_size: 0, max_pool_size: capacity, max_idle_pool_size: capacity, checkout_timeout: timeout) do conn = QUIC::Client.new(url) conn.family = (url.host == "www.youtube.com") ? CONFIG.force_resolve : Socket::Family::INET conn.family = Socket::Family::INET if conn.family == Socket::Family::UNSPEC From 03313438cc67b62c51ee74f26efcc7e68d8092cf Mon Sep 17 00:00:00 2001 From: Andrew Zhao Date: Sat, 10 Apr 2021 09:18:12 -0700 Subject: [PATCH 2/2] update deps --- shard.lock | 20 ++++++++------------ shard.yml | 11 ++++------- 2 files changed, 12 insertions(+), 19 deletions(-) diff --git a/shard.lock b/shard.lock index a9074b32e8..f47cbeb7c4 100644 --- a/shard.lock +++ b/shard.lock @@ -2,39 +2,35 @@ version: 2.0 shards: db: git: https://github.com/crystal-lang/crystal-db.git - version: 0.10.0 + version: 0.10.1 exception_page: git: https://github.com/crystal-loot/exception_page.git - version: 0.1.4 + version: 0.1.5 kemal: git: https://github.com/kemalcr/kemal.git - version: 0.27.0 + version: 1.0.0 kilt: git: https://github.com/jeromegn/kilt.git - version: 0.4.0 + version: 0.4.1 lsquic: git: https://github.com/iv-org/lsquic.cr.git - version: 2.18.1-1 + version: 2.18.1-2 pg: git: https://github.com/will/crystal-pg.git - version: 0.23.1 - - pool: - git: https://github.com/ysbaddaden/pool.git - version: 0.2.3 + version: 0.23.2 protodec: git: https://github.com/omarroth/protodec.git - version: 0.1.3 + version: 0.1.4 radix: git: https://github.com/luislavena/radix.git - version: 0.3.9 + version: 0.4.1 sqlite3: git: https://github.com/crystal-lang/crystal-sqlite3.git diff --git a/shard.yml b/shard.yml index 42eda04cab..2f92628622 100644 --- a/shard.yml +++ b/shard.yml @@ -12,23 +12,20 @@ targets: dependencies: pg: github: will/crystal-pg - version: ~> 0.23.1 + version: ~> 0.23.2 sqlite3: github: crystal-lang/crystal-sqlite3 version: ~> 0.18.0 kemal: github: kemalcr/kemal - version: ~> 0.27.0 - pool: - github: ysbaddaden/pool - version: ~> 0.2.3 + version: ~> 1.0.0 protodec: github: omarroth/protodec - version: ~> 0.1.3 + version: ~> 0.1.4 lsquic: github: iv-org/lsquic.cr version: ~> 2.18.1-1 -crystal: 0.36.1 +crystal: 1.0.0 license: AGPLv3