healthy_pools 2.2.3 → 2.2.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 7920f22d2bf5c1bb58d00ac099f15d2c074587e8
4
- data.tar.gz: b090b648aa7186b23387ac584d4851bf7ee3d947
3
+ metadata.gz: b4c8b30fd15908ff7eb26b3ce0c6026a7277924b
4
+ data.tar.gz: d98b81693b56c033a7a6e940948d63c9a43bf8b3
5
5
  SHA512:
6
- metadata.gz: 27e4679398276cc5f2fe3086a61cdaf487f7c90b3d1a3b1432ae5c3f88587f8eaa5164613c5880ea6a390d5c55fe11917d6024b2f13cd4a83e522cfe8f0b4819
7
- data.tar.gz: df8a0a87bed874e383c1516218e0e1678610e2d87e805952bb7f4a1222a498cd9d75e9b113fc2d1286de22debf5732573902fa5e48b9df78d0cc91f23776c34c
6
+ metadata.gz: ff3cbca55d9f022dcf3c6659a3362718bee709a08ef15f701d01ff91396c5634d4bf73a6211ecbb46799b3c5f2bc1d2970318c80525e12fa892dc6e6ff758839
7
+ data.tar.gz: a1f6de86f5ac0abc24609a4703f05926e5645144de3f075b2e80f094ad6a36b2e8021f7560db1ce50b56f897230d9f03fff44c3497539173bcf5f6ff5f1243ce
data/Changes.md CHANGED
@@ -98,7 +98,7 @@ end
98
98
  - We now reuse objects when possible.
99
99
 
100
100
  This means that under no contention, the same object will be checked
101
- out from the pool after subsequent calls to `ConnectionPool#with`.
101
+ out from the pool after subsequent calls to `HealthyPool#with`.
102
102
 
103
103
  This change should have no impact on end user performance. If
104
104
  anything, it should be an improvement, depending on what objects you
@@ -117,11 +117,11 @@ end
117
117
  0.9.0
118
118
  --------
119
119
 
120
- - Move method\_missing magic into ConnectionPool::Wrapper (djanowski)
120
+ - Move method\_missing magic into HealthyPool::Wrapper (djanowski)
121
121
  - Remove BasicObject superclass (djanowski)
122
122
 
123
123
  0.1.0
124
124
  --------
125
125
 
126
126
  - More precise timeouts and better error message
127
- - ConnectionPool now subclasses BasicObject so `method_missing` is more effective.
127
+ - HealthyPool now subclasses BasicObject so `method_missing` is more effective.
data/README.md CHANGED
@@ -19,7 +19,7 @@ Create a pool of objects to share amongst the fibers or threads in your Ruby
19
19
  application:
20
20
 
21
21
  ``` ruby
22
- $memcached = ConnectionPool.new(size: 5, timeout: 5) { Dalli::Client.new }
22
+ $memcached = HealthyPool.new(size: 5, timeout: 5) { Dalli::Client.new }
23
23
  ```
24
24
 
25
25
  Then use the pool in your application:
@@ -46,15 +46,15 @@ This will only modify the resource-get timeout for this particular
46
46
  invocation. This is useful if you want to fail-fast on certain non critical
47
47
  sections when a resource is not available, or conversely if you are comfortable
48
48
  blocking longer on a particular resource. This is not implemented in the below
49
- `ConnectionPool::Wrapper` class.
49
+ `HealthyPool::Wrapper` class.
50
50
 
51
51
  ## Migrating to a Connection Pool
52
52
 
53
- You can use `ConnectionPool::Wrapper` to wrap a single global connection,
53
+ You can use `HealthyPool::Wrapper` to wrap a single global connection,
54
54
  making it easier to migrate existing connection code over time:
55
55
 
56
56
  ``` ruby
57
- $redis = ConnectionPool::Wrapper.new(size: 5, timeout: 3) { Redis.connect }
57
+ $redis = HealthyPool::Wrapper.new(size: 5, timeout: 3) { Redis.connect }
58
58
  $redis.sadd('foo', 1)
59
59
  $redis.smembers('foo')
60
60
  ```
@@ -72,17 +72,17 @@ end
72
72
  ```
73
73
 
74
74
  Once you've ported your entire system to use `with`, you can simply remove
75
- `Wrapper` and use the simpler and faster `ConnectionPool`.
75
+ `Wrapper` and use the simpler and faster `HealthyPool`.
76
76
 
77
77
 
78
78
  ## Shutdown
79
79
 
80
- You can shut down a ConnectionPool instance once it should no longer be used.
80
+ You can shut down a HealthyPool instance once it should no longer be used.
81
81
  Further checkout attempts will immediately raise an error but existing checkouts
82
82
  will work.
83
83
 
84
84
  ```ruby
85
- cp = ConnectionPool.new { Redis.new }
85
+ cp = HealthyPool.new { Redis.new }
86
86
  cp.shutdown { |conn| conn.quit }
87
87
  ```
88
88
 
@@ -99,7 +99,7 @@ from the pool and a new one is created.
99
99
 
100
100
 
101
101
  ```ruby
102
- cp = ConnectionPool.new(health_check: lambda {|conn| conn.exec('select 1')}) { PG.connect }
102
+ cp = HealthyPool.new(health_check: lambda {|conn| conn.exec('select 1')}) { PG.connect }
103
103
  ```
104
104
 
105
105
 
@@ -1,9 +1,9 @@
1
1
  # -*- encoding: utf-8 -*-
2
- require "./lib/connection_pool/version"
2
+ require "./lib/healthy_pool/version"
3
3
 
4
4
  Gem::Specification.new do |s|
5
5
  s.name = "healthy_pools"
6
- s.version = ConnectionPool::VERSION
6
+ s.version = HealthyPool::VERSION
7
7
  s.platform = Gem::Platform::RUBY
8
8
  s.authors = ["Marco Montagna"]
9
9
  s.email = ["marcojoemontagna@gmail.com"]
@@ -5,7 +5,7 @@
5
5
 
6
6
  require 'thread'
7
7
 
8
- class ConnectionPool
8
+ class HealthyPool
9
9
 
10
10
  class_definition = Class.new do
11
11
 
@@ -6,7 +6,7 @@ require_relative 'monotonic_time'
6
6
  # Raised when you attempt to retrieve a connection from a pool that has been
7
7
  # shut down.
8
8
 
9
- class ConnectionPool::PoolShuttingDownError < RuntimeError; end
9
+ class HealthyPool::PoolShuttingDownError < RuntimeError; end
10
10
 
11
11
  ##
12
12
  # The TimedStack manages a pool of homogeneous connections (or any resource
@@ -27,7 +27,7 @@ class ConnectionPool::PoolShuttingDownError < RuntimeError; end
27
27
  # ts.pop timeout: 5
28
28
  # #=> raises Timeout::Error after 5 seconds
29
29
 
30
- class ConnectionPool::TimedStack
30
+ class HealthyPool::TimedStack
31
31
  attr_reader :max
32
32
 
33
33
  ##
@@ -89,10 +89,10 @@ class ConnectionPool::TimedStack
89
89
  options, timeout = timeout, 0.5 if Hash === timeout
90
90
  timeout = options.fetch :timeout, timeout
91
91
 
92
- deadline = ConnectionPool.monotonic_time + timeout
92
+ deadline = HealthyPool.monotonic_time + timeout
93
93
  @mutex.synchronize do
94
94
  loop do
95
- raise ConnectionPool::PoolShuttingDownError if @shutdown_block
95
+ raise HealthyPool::PoolShuttingDownError if @shutdown_block
96
96
  while connection_stored?(options)
97
97
  conn = fetch_connection(options)
98
98
  begin
@@ -108,7 +108,7 @@ class ConnectionPool::TimedStack
108
108
  connection = try_create(options)
109
109
  return connection if connection
110
110
 
111
- to_wait = deadline - ConnectionPool.monotonic_time
111
+ to_wait = deadline - HealthyPool.monotonic_time
112
112
  raise Timeout::Error, "Waited #{timeout} sec" if to_wait <= 0
113
113
  @resource.wait(@mutex, to_wait)
114
114
  end
@@ -0,0 +1,3 @@
1
+ class HealthyPool
2
+ VERSION = "2.2.4"
3
+ end
@@ -1,5 +1,5 @@
1
- require_relative 'connection_pool/version'
2
- require_relative 'connection_pool/timed_stack'
1
+ require_relative 'healthy_pool/version'
2
+ require_relative 'healthy_pool/timed_stack'
3
3
 
4
4
 
5
5
  # Generic connection pool class for e.g. sharing a limited number of network connections
@@ -7,7 +7,7 @@ require_relative 'connection_pool/timed_stack'
7
7
  #
8
8
  # Example usage with block (faster):
9
9
  #
10
- # @pool = ConnectionPool.new { Redis.new }
10
+ # @pool = HealthyPool.new { Redis.new }
11
11
  #
12
12
  # @pool.with do |redis|
13
13
  # redis.lpop('my-list') if redis.llen('my-list') > 0
@@ -21,7 +21,7 @@ require_relative 'connection_pool/timed_stack'
21
21
  #
22
22
  # Example usage replacing an existing connection (slower):
23
23
  #
24
- # $redis = ConnectionPool.wrap { Redis.new }
24
+ # $redis = HealthyPool.wrap { Redis.new }
25
25
  #
26
26
  # def do_work
27
27
  # $redis.lpop('my-list') if $redis.llen('my-list') > 0
@@ -31,7 +31,7 @@ require_relative 'connection_pool/timed_stack'
31
31
  # - :size - number of connections to pool, defaults to 5
32
32
  # - :timeout - amount of time to wait for a connection if none currently available, defaults to 5 seconds
33
33
  #
34
- class ConnectionPool
34
+ class HealthyPool
35
35
  DEFAULTS = {size: 5, timeout: 5, health_check: nil}
36
36
 
37
37
  class Error < RuntimeError
@@ -104,7 +104,7 @@ end
104
104
  ::Thread.current[@key_count]-= 1
105
105
  end
106
106
  else
107
- raise ConnectionPool::Error, 'no connections are checked out'
107
+ raise HealthyPool::Error, 'no connections are checked out'
108
108
  end
109
109
 
110
110
  nil
@@ -130,7 +130,7 @@ end
130
130
  METHODS = [:with, :pool_shutdown]
131
131
 
132
132
  def initialize(options = {}, &block)
133
- @pool = options.fetch(:pool) { ::ConnectionPool.new(options, &block) }
133
+ @pool = options.fetch(:pool) { ::HealthyPool.new(options, &block) }
134
134
  end
135
135
 
136
136
  def with(&block)
data/test/helper.rb CHANGED
@@ -5,4 +5,4 @@ require 'minitest/autorun'
5
5
 
6
6
  $VERBOSE = 1
7
7
 
8
- require_relative '../lib/connection_pool'
8
+ require_relative '../lib/healthy_pool'
@@ -1,6 +1,6 @@
1
1
  require_relative 'helper'
2
2
 
3
- class TestConnectionPool < Minitest::Test
3
+ class TestHealthyPool < Minitest::Test
4
4
 
5
5
  class NetworkConnection
6
6
  SLEEP_TIME = 0.1
@@ -61,7 +61,7 @@ class TestConnectionPool < Minitest::Test
61
61
 
62
62
  def test_basic_multithreaded_usage
63
63
  pool_size = 5
64
- pool = ConnectionPool.new(size: pool_size) { NetworkConnection.new }
64
+ pool = HealthyPool.new(size: pool_size) { NetworkConnection.new }
65
65
 
66
66
  start = Time.new
67
67
 
@@ -83,7 +83,7 @@ class TestConnectionPool < Minitest::Test
83
83
  end
84
84
 
85
85
  def test_timeout
86
- pool = ConnectionPool.new(timeout: 0, size: 1) { NetworkConnection.new }
86
+ pool = HealthyPool.new(timeout: 0, size: 1) { NetworkConnection.new }
87
87
  thread = Thread.new do
88
88
  pool.with do |net|
89
89
  net.do_something
@@ -105,7 +105,7 @@ class TestConnectionPool < Minitest::Test
105
105
  end
106
106
 
107
107
  def test_with
108
- pool = ConnectionPool.new(timeout: 0, size: 1) { Object.new }
108
+ pool = HealthyPool.new(timeout: 0, size: 1) { Object.new }
109
109
 
110
110
  pool.with do
111
111
  assert_raises Timeout::Error do
@@ -117,7 +117,7 @@ class TestConnectionPool < Minitest::Test
117
117
  end
118
118
 
119
119
  def test_with_timeout
120
- pool = ConnectionPool.new(timeout: 0, size: 1) { Object.new }
120
+ pool = HealthyPool.new(timeout: 0, size: 1) { Object.new }
121
121
 
122
122
  assert_raises Timeout::Error do
123
123
  Timeout.timeout(0.01) do
@@ -133,7 +133,7 @@ class TestConnectionPool < Minitest::Test
133
133
  def test_checkout_ignores_timeout
134
134
  skip("Thread.handle_interrupt not available") unless Thread.respond_to?(:handle_interrupt)
135
135
 
136
- pool = ConnectionPool.new(timeout: 0, size: 1) { Object.new }
136
+ pool = HealthyPool.new(timeout: 0, size: 1) { Object.new }
137
137
  def pool.checkout(options)
138
138
  sleep 0.015
139
139
  super
@@ -157,7 +157,7 @@ class TestConnectionPool < Minitest::Test
157
157
  end
158
158
 
159
159
  def test_explicit_return
160
- pool = ConnectionPool.new(timeout: 0, size: 1) do
160
+ pool = HealthyPool.new(timeout: 0, size: 1) do
161
161
  mock = Minitest::Mock.new
162
162
  def mock.disconnect!
163
163
  raise "should not disconnect upon explicit return"
@@ -171,7 +171,7 @@ class TestConnectionPool < Minitest::Test
171
171
  end
172
172
 
173
173
  def test_with_timeout_override
174
- pool = ConnectionPool.new(timeout: 0, size: 1) { NetworkConnection.new }
174
+ pool = HealthyPool.new(timeout: 0, size: 1) { NetworkConnection.new }
175
175
 
176
176
  t = Thread.new do
177
177
  pool.with do |net|
@@ -192,7 +192,7 @@ class TestConnectionPool < Minitest::Test
192
192
  end
193
193
 
194
194
  def test_checkin
195
- pool = ConnectionPool.new(timeout: 0, size: 1) { NetworkConnection.new }
195
+ pool = HealthyPool.new(timeout: 0, size: 1) { NetworkConnection.new }
196
196
  conn = pool.checkout
197
197
 
198
198
  assert_raises Timeout::Error do
@@ -205,14 +205,14 @@ class TestConnectionPool < Minitest::Test
205
205
  end
206
206
 
207
207
  def test_returns_value
208
- pool = ConnectionPool.new(timeout: 0, size: 1) { Object.new }
208
+ pool = HealthyPool.new(timeout: 0, size: 1) { Object.new }
209
209
  assert_equal 1, pool.with {|o| 1 }
210
210
  end
211
211
 
212
212
  def test_checkin_never_checkout
213
- pool = ConnectionPool.new(timeout: 0, size: 1) { Object.new }
213
+ pool = HealthyPool.new(timeout: 0, size: 1) { Object.new }
214
214
 
215
- e = assert_raises ConnectionPool::Error do
215
+ e = assert_raises HealthyPool::Error do
216
216
  pool.checkin
217
217
  end
218
218
 
@@ -220,18 +220,18 @@ class TestConnectionPool < Minitest::Test
220
220
  end
221
221
 
222
222
  def test_checkin_no_current_checkout
223
- pool = ConnectionPool.new(timeout: 0, size: 1) { Object.new }
223
+ pool = HealthyPool.new(timeout: 0, size: 1) { Object.new }
224
224
 
225
225
  pool.checkout
226
226
  pool.checkin
227
227
 
228
- assert_raises ConnectionPool::Error do
228
+ assert_raises HealthyPool::Error do
229
229
  pool.checkin
230
230
  end
231
231
  end
232
232
 
233
233
  def test_checkin_twice
234
- pool = ConnectionPool.new(timeout: 0, size: 1) { Object.new }
234
+ pool = HealthyPool.new(timeout: 0, size: 1) { Object.new }
235
235
 
236
236
  pool.checkout
237
237
  pool.checkout
@@ -250,7 +250,7 @@ class TestConnectionPool < Minitest::Test
250
250
  end
251
251
 
252
252
  def test_checkout
253
- pool = ConnectionPool.new(size: 1) { NetworkConnection.new }
253
+ pool = HealthyPool.new(size: 1) { NetworkConnection.new }
254
254
 
255
255
  conn = pool.checkout
256
256
 
@@ -260,7 +260,7 @@ class TestConnectionPool < Minitest::Test
260
260
  end
261
261
 
262
262
  def test_checkout_multithread
263
- pool = ConnectionPool.new(size: 2) { NetworkConnection.new }
263
+ pool = HealthyPool.new(size: 2) { NetworkConnection.new }
264
264
  conn = pool.checkout
265
265
 
266
266
  t = Thread.new do
@@ -271,7 +271,7 @@ class TestConnectionPool < Minitest::Test
271
271
  end
272
272
 
273
273
  def test_checkout_timeout
274
- pool = ConnectionPool.new(timeout: 0, size: 0) { Object.new }
274
+ pool = HealthyPool.new(timeout: 0, size: 0) { Object.new }
275
275
 
276
276
  assert_raises Timeout::Error do
277
277
  pool.checkout
@@ -279,7 +279,7 @@ class TestConnectionPool < Minitest::Test
279
279
  end
280
280
 
281
281
  def test_checkout_timeout_override
282
- pool = ConnectionPool.new(timeout: 0, size: 1) { NetworkConnection.new }
282
+ pool = HealthyPool.new(timeout: 0, size: 1) { NetworkConnection.new }
283
283
 
284
284
  thread = Thread.new do
285
285
  pool.with do |net|
@@ -298,7 +298,7 @@ class TestConnectionPool < Minitest::Test
298
298
  end
299
299
 
300
300
  def test_passthru
301
- pool = ConnectionPool.wrap(timeout: 2 * NetworkConnection::SLEEP_TIME, size: 1) { NetworkConnection.new }
301
+ pool = HealthyPool.wrap(timeout: 2 * NetworkConnection::SLEEP_TIME, size: 1) { NetworkConnection.new }
302
302
  assert_equal 1, pool.do_something
303
303
  assert_equal 2, pool.do_something
304
304
  assert_equal 5, pool.do_something_with_block { 3 }
@@ -306,7 +306,7 @@ class TestConnectionPool < Minitest::Test
306
306
  end
307
307
 
308
308
  def test_passthru_respond_to
309
- pool = ConnectionPool.wrap(timeout: 2 * NetworkConnection::SLEEP_TIME, size: 1) { NetworkConnection.new }
309
+ pool = HealthyPool.wrap(timeout: 2 * NetworkConnection::SLEEP_TIME, size: 1) { NetworkConnection.new }
310
310
  assert pool.respond_to?(:with)
311
311
  assert pool.respond_to?(:do_something)
312
312
  assert pool.respond_to?(:do_magic)
@@ -314,7 +314,7 @@ class TestConnectionPool < Minitest::Test
314
314
  end
315
315
 
316
316
  def test_return_value
317
- pool = ConnectionPool.new(timeout: 2 * NetworkConnection::SLEEP_TIME, size: 1) { NetworkConnection.new }
317
+ pool = HealthyPool.new(timeout: 2 * NetworkConnection::SLEEP_TIME, size: 1) { NetworkConnection.new }
318
318
  result = pool.with do |net|
319
319
  net.fast
320
320
  end
@@ -322,7 +322,7 @@ class TestConnectionPool < Minitest::Test
322
322
  end
323
323
 
324
324
  def test_heavy_threading
325
- pool = ConnectionPool.new(timeout: 0.5, size: 3) { NetworkConnection.new }
325
+ pool = HealthyPool.new(timeout: 0.5, size: 3) { NetworkConnection.new }
326
326
 
327
327
  threads = Array.new(20) do
328
328
  Thread.new do
@@ -336,7 +336,7 @@ class TestConnectionPool < Minitest::Test
336
336
  end
337
337
 
338
338
  def test_reuses_objects_when_pool_not_saturated
339
- pool = ConnectionPool.new(size: 5) { NetworkConnection.new }
339
+ pool = HealthyPool.new(size: 5) { NetworkConnection.new }
340
340
 
341
341
  ids = 10.times.map do
342
342
  pool.with { |c| c.object_id }
@@ -346,7 +346,7 @@ class TestConnectionPool < Minitest::Test
346
346
  end
347
347
 
348
348
  def test_failed_health_check_removes_failed_connections
349
- pool = ConnectionPool.new(size: 5, health_check: lambda {|x| false}) { NetworkConnection.new }
349
+ pool = HealthyPool.new(size: 5, health_check: lambda {|x| false}) { NetworkConnection.new }
350
350
 
351
351
  ids = 10.times.map do
352
352
  pool.with { |c| c.object_id }
@@ -356,7 +356,7 @@ class TestConnectionPool < Minitest::Test
356
356
  end
357
357
 
358
358
  def test_exceptions_during_health_check_removes_connections
359
- pool = ConnectionPool.new(size: 5, health_check: lambda {|x| raise "failed"}) { NetworkConnection.new }
359
+ pool = HealthyPool.new(size: 5, health_check: lambda {|x| raise "failed"}) { NetworkConnection.new }
360
360
 
361
361
  ids = 10.times.map do
362
362
  pool.with { |c| c.object_id }
@@ -366,7 +366,7 @@ class TestConnectionPool < Minitest::Test
366
366
  end
367
367
 
368
368
  def test_failed_health_check_does_not_remove_good_connections
369
- pool = ConnectionPool.new(size: 5, health_check: lambda {|x| true}) { NetworkConnection.new }
369
+ pool = HealthyPool.new(size: 5, health_check: lambda {|x| true}) { NetworkConnection.new }
370
370
 
371
371
  ids = 10.times.map do
372
372
  pool.with { |c| c.object_id }
@@ -377,7 +377,7 @@ class TestConnectionPool < Minitest::Test
377
377
 
378
378
  def test_nested_checkout
379
379
  recorder = Recorder.new
380
- pool = ConnectionPool.new(size: 1) { recorder }
380
+ pool = HealthyPool.new(size: 1) { recorder }
381
381
  pool.with do |r_outer|
382
382
  @other = Thread.new do |t|
383
383
  pool.with do |r_other|
@@ -402,7 +402,7 @@ class TestConnectionPool < Minitest::Test
402
402
  def test_shutdown_is_executed_for_all_connections
403
403
  recorders = []
404
404
 
405
- pool = ConnectionPool.new(size: 3) do
405
+ pool = HealthyPool.new(size: 3) do
406
406
  Recorder.new.tap { |r| recorders << r }
407
407
  end
408
408
 
@@ -418,11 +418,11 @@ class TestConnectionPool < Minitest::Test
418
418
  end
419
419
 
420
420
  def test_raises_error_after_shutting_down
421
- pool = ConnectionPool.new(size: 1) { true }
421
+ pool = HealthyPool.new(size: 1) { true }
422
422
 
423
423
  pool.shutdown { }
424
424
 
425
- assert_raises ConnectionPool::PoolShuttingDownError do
425
+ assert_raises HealthyPool::PoolShuttingDownError do
426
426
  pool.checkout
427
427
  end
428
428
  end
@@ -430,7 +430,7 @@ class TestConnectionPool < Minitest::Test
430
430
  def test_runs_shutdown_block_asynchronously_if_connection_was_in_use
431
431
  recorders = []
432
432
 
433
- pool = ConnectionPool.new(size: 3) do
433
+ pool = HealthyPool.new(size: 3) do
434
434
  Recorder.new.tap { |r| recorders << r }
435
435
  end
436
436
 
@@ -452,7 +452,7 @@ class TestConnectionPool < Minitest::Test
452
452
  end
453
453
 
454
454
  def test_raises_an_error_if_shutdown_is_called_without_a_block
455
- pool = ConnectionPool.new(size: 1) { }
455
+ pool = HealthyPool.new(size: 1) { }
456
456
 
457
457
  assert_raises ArgumentError do
458
458
  pool.shutdown
@@ -462,7 +462,7 @@ class TestConnectionPool < Minitest::Test
462
462
  def test_shutdown_is_executed_for_all_connections_in_wrapped_pool
463
463
  recorders = []
464
464
 
465
- wrapper = ConnectionPool::Wrapper.new(size: 3) do
465
+ wrapper = HealthyPool::Wrapper.new(size: 3) do
466
466
  Recorder.new.tap { |r| recorders << r }
467
467
  end
468
468
 
@@ -478,13 +478,13 @@ class TestConnectionPool < Minitest::Test
478
478
  end
479
479
 
480
480
  def test_wrapper_method_missing
481
- wrapper = ConnectionPool::Wrapper.new { NetworkConnection.new }
481
+ wrapper = HealthyPool::Wrapper.new { NetworkConnection.new }
482
482
 
483
483
  assert_equal 1, wrapper.fast
484
484
  end
485
485
 
486
486
  def test_wrapper_respond_to_eh
487
- wrapper = ConnectionPool::Wrapper.new { NetworkConnection.new }
487
+ wrapper = HealthyPool::Wrapper.new { NetworkConnection.new }
488
488
 
489
489
  assert_respond_to wrapper, :with
490
490
 
@@ -493,7 +493,7 @@ class TestConnectionPool < Minitest::Test
493
493
  end
494
494
 
495
495
  def test_wrapper_with
496
- wrapper = ConnectionPool::Wrapper.new(timeout: 0, size: 1) { Object.new }
496
+ wrapper = HealthyPool::Wrapper.new(timeout: 0, size: 1) { Object.new }
497
497
 
498
498
  wrapper.with do
499
499
  assert_raises Timeout::Error do
@@ -513,15 +513,15 @@ class TestConnectionPool < Minitest::Test
513
513
  end
514
514
 
515
515
  def test_wrapper_kernel_methods
516
- wrapper = ConnectionPool::Wrapper.new(timeout: 0, size: 1) { ConnWithEval.new }
516
+ wrapper = HealthyPool::Wrapper.new(timeout: 0, size: 1) { ConnWithEval.new }
517
517
 
518
518
  assert_equal "eval'ed 1", wrapper.eval(1)
519
519
  end
520
520
 
521
521
  def test_wrapper_with_connection_pool
522
522
  recorder = Recorder.new
523
- pool = ConnectionPool.new(size: 1) { recorder }
524
- wrapper = ConnectionPool::Wrapper.new(pool: pool)
523
+ pool = HealthyPool.new(size: 1) { recorder }
524
+ wrapper = HealthyPool::Wrapper.new(pool: pool)
525
525
 
526
526
  pool.with { |r| r.do_work('with') }
527
527
  wrapper.do_work('wrapped')
@@ -530,14 +530,14 @@ class TestConnectionPool < Minitest::Test
530
530
  end
531
531
 
532
532
  def test_stats_without_active_connection
533
- pool = ConnectionPool.new(size: 2) { NetworkConnection.new }
533
+ pool = HealthyPool.new(size: 2) { NetworkConnection.new }
534
534
 
535
535
  assert_equal(2, pool.size)
536
536
  assert_equal(2, pool.available)
537
537
  end
538
538
 
539
539
  def test_stats_with_active_connection
540
- pool = ConnectionPool.new(size: 2) { NetworkConnection.new }
540
+ pool = HealthyPool.new(size: 2) { NetworkConnection.new }
541
541
 
542
542
  pool.with do
543
543
  assert_equal(1, pool.available)
@@ -1,13 +1,13 @@
1
1
  require_relative 'helper'
2
2
 
3
- class TestConnectionPoolTimedStack < Minitest::Test
3
+ class TestHealthyPoolTimedStack < Minitest::Test
4
4
 
5
5
  def setup
6
- @stack = ConnectionPool::TimedStack.new { Object.new }
6
+ @stack = HealthyPool::TimedStack.new { Object.new }
7
7
  end
8
8
 
9
9
  def test_empty_eh
10
- stack = ConnectionPool::TimedStack.new(1) { Object.new }
10
+ stack = HealthyPool::TimedStack.new(1) { Object.new }
11
11
 
12
12
  refute_empty stack
13
13
 
@@ -21,7 +21,7 @@ class TestConnectionPoolTimedStack < Minitest::Test
21
21
  end
22
22
 
23
23
  def test_length
24
- stack = ConnectionPool::TimedStack.new(1) { Object.new }
24
+ stack = HealthyPool::TimedStack.new(1) { Object.new }
25
25
 
26
26
  assert_equal 1, stack.length
27
27
 
@@ -35,7 +35,7 @@ class TestConnectionPoolTimedStack < Minitest::Test
35
35
  end
36
36
 
37
37
  def test_object_creation_fails
38
- stack = ConnectionPool::TimedStack.new(2) { raise 'failure' }
38
+ stack = HealthyPool::TimedStack.new(2) { raise 'failure' }
39
39
 
40
40
  begin
41
41
  stack.pop
@@ -79,7 +79,7 @@ class TestConnectionPoolTimedStack < Minitest::Test
79
79
  end
80
80
 
81
81
  def test_pop_full
82
- stack = ConnectionPool::TimedStack.new(1) { Object.new }
82
+ stack = HealthyPool::TimedStack.new(1) { Object.new }
83
83
 
84
84
  popped = stack.pop
85
85
 
@@ -104,13 +104,13 @@ class TestConnectionPoolTimedStack < Minitest::Test
104
104
  def test_pop_shutdown
105
105
  @stack.shutdown { }
106
106
 
107
- assert_raises ConnectionPool::PoolShuttingDownError do
107
+ assert_raises HealthyPool::PoolShuttingDownError do
108
108
  @stack.pop
109
109
  end
110
110
  end
111
111
 
112
112
  def test_push
113
- stack = ConnectionPool::TimedStack.new(1) { Object.new }
113
+ stack = HealthyPool::TimedStack.new(1) { Object.new }
114
114
 
115
115
  conn = stack.pop
116
116
 
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: healthy_pools
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.2.3
4
+ version: 2.2.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - Marco Montagna
@@ -67,13 +67,13 @@ files:
67
67
  - README.md
68
68
  - Rakefile
69
69
  - healthy_pools.gemspec
70
- - lib/connection_pool.rb
71
- - lib/connection_pool/monotonic_time.rb
72
- - lib/connection_pool/timed_stack.rb
73
- - lib/connection_pool/version.rb
70
+ - lib/healthy_pool.rb
71
+ - lib/healthy_pool/monotonic_time.rb
72
+ - lib/healthy_pool/timed_stack.rb
73
+ - lib/healthy_pool/version.rb
74
74
  - test/helper.rb
75
- - test/test_connection_pool.rb
76
- - test/test_connection_pool_timed_stack.rb
75
+ - test/test_healthy_pool.rb
76
+ - test/test_healthy_pool_timed_stack.rb
77
77
  homepage: https://github.com/mmontagna/healthy_pools
78
78
  licenses:
79
79
  - MIT
@@ -1,3 +0,0 @@
1
- class ConnectionPool
2
- VERSION = "2.2.3"
3
- end