From c0388d64795e4740faf1f4a1d4a0c8c97273d0a1 Mon Sep 17 00:00:00 2001 From: Michael Rykov Date: Sun, 29 Oct 2023 13:35:38 +0800 Subject: [PATCH] Fixed pool options for Redis 5.0 --- .github/workflows/specs.yml | 15 +++++++++++++-- Gemfile | 6 ++++-- lib/pools/connection_pool.rb | 2 +- lib/pools/pooled.rb | 4 +++- pools.gemspec | 2 +- 5 files changed, 22 insertions(+), 7 deletions(-) diff --git a/.github/workflows/specs.yml b/.github/workflows/specs.yml index fee76e4..855ff41 100644 --- a/.github/workflows/specs.yml +++ b/.github/workflows/specs.yml @@ -9,12 +9,23 @@ on: jobs: test: runs-on: ubuntu-latest + strategy: fail-fast: true matrix: - ruby: [2.2, 2.3, 2.4, 2.5, 2.6, 2.7, 3.0, head, jruby] + ruby: ["2.3", "2.4", "2.5", "2.6", "2.7", "3.0", "3.1", "3.2", "head", "jruby"] + redis: ["3.0", "4.0", "5.0"] + exclude: + - ruby: "2.3" + redis: "5.0" + - ruby: "2.4" + redis: "5.0" + + env: + REDIS_VERSION: "${{matrix.redis}}" + steps: - - uses: actions/checkout@v3 + - uses: actions/checkout@v4 - name: Set up Ruby & run Bundler uses: ruby/setup-ruby@v1 with: diff --git a/Gemfile b/Gemfile index ed7e8a2..9881e49 100644 --- a/Gemfile +++ b/Gemfile @@ -1,11 +1,13 @@ source "https://rubygems.org" +REDIS_VERSION = ENV.fetch("REDIS_VERSION", '5.0').freeze + # Gemspec only lists command-line tool dependencies gemspec # Not-required for execution group :development, :test do + gem 'redis', "~> #{REDIS_VERSION}" gem 'rake', '>= 12.3.3' gem 'rspec', '~> 3.0' - gem 'redis', '< 4.0' -end \ No newline at end of file +end diff --git a/lib/pools/connection_pool.rb b/lib/pools/connection_pool.rb index e202a4a..f89502f 100644 --- a/lib/pools/connection_pool.rb +++ b/lib/pools/connection_pool.rb @@ -83,7 +83,7 @@ def initialize(pooled, options) @timeout = options[:wait_timeout] || 5 # default max pool size to 5 - @size = (options[:pool] && options[:pool].to_i) || 5 + @size = (@options.delete(:pool) || 5).to_i @connections = [] @checked_out = [] diff --git a/lib/pools/pooled.rb b/lib/pools/pooled.rb index 04ba4c6..758ffa2 100644 --- a/lib/pools/pooled.rb +++ b/lib/pools/pooled.rb @@ -8,9 +8,11 @@ module Pooled def initialize(*args) options = args.extract_options! + pool_name = options.delete(:pool_name) + @preparation_chain = [] @connection_pool = ConnectionPool.new(self, options) - Pools.handler.add(@connection_pool, options[:pool_name]) + Pools.handler.add(@connection_pool, pool_name) end def with_connection(&block) diff --git a/pools.gemspec b/pools.gemspec index 4c78a05..1a53df8 100644 --- a/pools.gemspec +++ b/pools.gemspec @@ -1,6 +1,6 @@ Gem::Specification.new do |s| s.name = "pools" - s.version = "2.0.0" + s.version = "2.0.1" s.date = Time.now.strftime('%Y-%m-%d') s.summary = "Generalized connection pooling" s.homepage = "http://github.com/rykov/pools"