From 99b81aa0a9dccb3b423260740ce2d603f1479356 Mon Sep 17 00:00:00 2001 From: Thomas Lecavelier Date: Fri, 1 Mar 2019 16:43:49 +0100 Subject: [PATCH] mperham/connection_pool#113 expose pool from Wrapper (#114) * mperham/connection_pool#113 expose pool from Wrapper * mperham/connection_pool#113 Fill Changes.md * mperham/connection_pool#113 PR comment: rename #pool to #wrapped_pool --- Changes.md | 1 + lib/connection_pool.rb | 6 +++++- test/test_connection_pool.rb | 5 +++++ 3 files changed, 11 insertions(+), 1 deletion(-) diff --git a/Changes.md b/Changes.md index ed78529..bd4cf0b 100644 --- a/Changes.md +++ b/Changes.md @@ -6,6 +6,7 @@ HEAD - Use monotonic clock present in all modern Rubies [Tero Tasanen, #109] - Remove code hacks necessary for JRuby 1.7 +- Expose wrapped pool from ConnectionPool::Wrapper [Thomas Lecavelier, #113] 2.2.2 ------ diff --git a/lib/connection_pool.rb b/lib/connection_pool.rb index ce88f08..037c076 100644 --- a/lib/connection_pool.rb +++ b/lib/connection_pool.rb @@ -109,12 +109,16 @@ def available private class Wrapper < ::BasicObject - METHODS = [:with, :pool_shutdown] + METHODS = [:with, :pool_shutdown, :wrapped_pool] def initialize(options = {}, &block) @pool = options.fetch(:pool) { ::ConnectionPool.new(options, &block) } end + def wrapped_pool + @pool + end + def with(&block) @pool.with(&block) end diff --git a/test/test_connection_pool.rb b/test/test_connection_pool.rb index b88701e..4aa0c0a 100644 --- a/test/test_connection_pool.rb +++ b/test/test_connection_pool.rb @@ -474,6 +474,11 @@ def test_shutdown_is_executed_for_all_connections_in_wrapped_pool assert_equal [["shutdown"]] * 3, recorders.map { |r| r.calls } end + def test_wrapper_wrapped_pool + wrapper = ConnectionPool::Wrapper.new { NetworkConnection.new } + assert_equal ConnectionPool, wrapper.wrapped_pool.class + end + def test_wrapper_method_missing wrapper = ConnectionPool::Wrapper.new { NetworkConnection.new }