Skip to content

Commit

Permalink
#113 expose pool from Wrapper (#114)
Browse files Browse the repository at this point in the history
* #113 expose pool from Wrapper

* #113 Fill Changes.md

* #113 PR comment: rename #pool to #wrapped_pool
  • Loading branch information
ook authored and mperham committed Mar 1, 2019
1 parent a08fb8f commit 99b81aa
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 1 deletion.
1 change: 1 addition & 0 deletions Changes.md
Expand Up @@ -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
------
Expand Down
6 changes: 5 additions & 1 deletion lib/connection_pool.rb
Expand Up @@ -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
Expand Down
5 changes: 5 additions & 0 deletions test/test_connection_pool.rb
Expand Up @@ -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 }

Expand Down

0 comments on commit 99b81aa

Please sign in to comment.