gene_pool 1.3.0 → 1.3.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/lib/gene_pool.rb +4 -4
- data/test/gene_pool_test.rb +13 -10
- metadata +7 -15
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 4483f6b4f3352edd3db3b1ef21dd48b0970e71a3
|
4
|
+
data.tar.gz: f7590686a995b971cee9a146c4763a786c22cd45
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 9e929a7c83cb4fa6562d9a1b735d3ccfff704b7e72f09c1c8947d4648350c6313d115f598e22af0c1fd07b2743b482fa1fd2f6bf15876d075de61c59d60f532e
|
7
|
+
data.tar.gz: e4e139e114c6c1ce496e658fd464521007137ba33eeecabb61533dbb6130d5360eccfe9871bdf66a179ff49f1be7793a7fbe656486bf11d5acd46e0ff7d0a68b
|
data/lib/gene_pool.rb
CHANGED
@@ -98,7 +98,7 @@ class GenePool
|
|
98
98
|
elsif @idle_timeout && (Time.now - connection._last_used) >= @idle_timeout
|
99
99
|
connection = renew(connection)
|
100
100
|
end
|
101
|
-
|
101
|
+
|
102
102
|
@logger.debug {"#{@name}: Checkout connection #{connection}(#{connection.object_id}) self=#{self}"}
|
103
103
|
return connection
|
104
104
|
end
|
@@ -117,7 +117,7 @@ class GenePool
|
|
117
117
|
end
|
118
118
|
@logger.debug {"#{@name}: Checkin connection #{connection}(#{connection.object_id}) self=#{self}"}
|
119
119
|
end
|
120
|
-
|
120
|
+
|
121
121
|
# Create a scope for checking out a connection
|
122
122
|
# The client should handle cleanup on exception which should be something similar to the following:
|
123
123
|
# rescue Exception => e
|
@@ -218,7 +218,7 @@ class GenePool
|
|
218
218
|
@logger.debug {"#{@name}: Renewed connection old=#{old_connection.object_id} new=#{new_connection}(#{new_connection.object_id})"}
|
219
219
|
return new_connection
|
220
220
|
end
|
221
|
-
|
221
|
+
|
222
222
|
# Perform the given block for each connection. Note that close should be used for safely closing all connections
|
223
223
|
# This should probably only ever be used to allow interrupt of a connection that is checked out?
|
224
224
|
def each
|
@@ -270,7 +270,7 @@ class GenePool
|
|
270
270
|
# Thread is used as a reserved_connection_placeholder so don't close the connection if it's actually a thread
|
271
271
|
return if connection.kind_of?(Thread)
|
272
272
|
if @close_proc.kind_of?(Symbol)
|
273
|
-
connection.
|
273
|
+
connection.__send__(@close_proc)
|
274
274
|
else
|
275
275
|
@close_proc.call(connection)
|
276
276
|
end
|
data/test/gene_pool_test.rb
CHANGED
@@ -19,7 +19,7 @@ class DummyConnection
|
|
19
19
|
@closed = false
|
20
20
|
@other_closed = false
|
21
21
|
end
|
22
|
-
|
22
|
+
|
23
23
|
def to_s
|
24
24
|
@count.to_s
|
25
25
|
end
|
@@ -43,8 +43,12 @@ class DummyConnection
|
|
43
43
|
def other_closed?
|
44
44
|
@other_closed
|
45
45
|
end
|
46
|
+
|
47
|
+
def send(msg, flags)
|
48
|
+
# override Object#send ( to simulate e.g. BasicSocket#send )
|
49
|
+
end
|
46
50
|
end
|
47
|
-
|
51
|
+
|
48
52
|
|
49
53
|
class GenePoolTest < Test::Unit::TestCase
|
50
54
|
|
@@ -60,7 +64,7 @@ class GenePoolTest < Test::Unit::TestCase
|
|
60
64
|
assert @gene_pool.logger
|
61
65
|
end
|
62
66
|
end
|
63
|
-
|
67
|
+
|
64
68
|
context '' do
|
65
69
|
setup do
|
66
70
|
#@stringio = StringIO.new
|
@@ -101,7 +105,7 @@ class GenePoolTest < Test::Unit::TestCase
|
|
101
105
|
assert_equal 0, @gene_pool.checked_out.size
|
102
106
|
end
|
103
107
|
end
|
104
|
-
|
108
|
+
|
105
109
|
should 'create 2 connections' do
|
106
110
|
conn1 = @gene_pool.checkout
|
107
111
|
(1..3).each do |i|
|
@@ -120,7 +124,7 @@ class GenePoolTest < Test::Unit::TestCase
|
|
120
124
|
@gene_pool.checkin(conn1)
|
121
125
|
assert_equal 0, @gene_pool.checked_out.size
|
122
126
|
end
|
123
|
-
|
127
|
+
|
124
128
|
should 'be able to reset multiple times' do
|
125
129
|
@gene_pool.with_connection do |conn1|
|
126
130
|
conn2 = @gene_pool.renew(conn1)
|
@@ -134,7 +138,7 @@ class GenePoolTest < Test::Unit::TestCase
|
|
134
138
|
assert_equal 1, @gene_pool.connections.size
|
135
139
|
assert_equal 0, @gene_pool.checked_out.size
|
136
140
|
end
|
137
|
-
|
141
|
+
|
138
142
|
should 'be able to remove connection' do
|
139
143
|
@gene_pool.with_connection do |conn|
|
140
144
|
@gene_pool.remove(conn)
|
@@ -144,7 +148,7 @@ class GenePoolTest < Test::Unit::TestCase
|
|
144
148
|
assert_equal 0, @gene_pool.connections.size
|
145
149
|
assert_equal 0, @gene_pool.checked_out.size
|
146
150
|
end
|
147
|
-
|
151
|
+
|
148
152
|
should 'be able to remove multiple connections' do
|
149
153
|
@gene_pool.with_connection do |conn1|
|
150
154
|
@gene_pool.with_connection do |conn2|
|
@@ -165,7 +169,7 @@ class GenePoolTest < Test::Unit::TestCase
|
|
165
169
|
assert_equal 1, @gene_pool.connections.size
|
166
170
|
assert_equal 0, @gene_pool.checked_out.size
|
167
171
|
end
|
168
|
-
|
172
|
+
|
169
173
|
should 'handle aborted connection' do
|
170
174
|
@gene_pool.with_connection do |conn1|
|
171
175
|
@sleep = 2
|
@@ -188,7 +192,7 @@ class GenePoolTest < Test::Unit::TestCase
|
|
188
192
|
end
|
189
193
|
end
|
190
194
|
end
|
191
|
-
|
195
|
+
|
192
196
|
should 'not allow more than pool_size connections' do
|
193
197
|
conns = []
|
194
198
|
pool_size = @gene_pool.pool_size
|
@@ -368,7 +372,6 @@ class GenePoolTest < Test::Unit::TestCase
|
|
368
372
|
assert conn.other_closed?
|
369
373
|
end
|
370
374
|
|
371
|
-
|
372
375
|
should 'allow nil so it does not execute a close' do
|
373
376
|
@gene_pool = GenePool.new(:close_proc => nil) do
|
374
377
|
DummyConnection.new(0, 0)
|
metadata
CHANGED
@@ -1,15 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: gene_pool
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.3.
|
5
|
-
prerelease:
|
4
|
+
version: 1.3.1
|
6
5
|
platform: ruby
|
7
6
|
authors:
|
8
7
|
- Brad Pardee
|
9
8
|
autorequire:
|
10
9
|
bindir: bin
|
11
10
|
cert_chain: []
|
12
|
-
date:
|
11
|
+
date: 2013-12-05 00:00:00.000000000 Z
|
13
12
|
dependencies: []
|
14
13
|
description: Generic pooling library for creating a connection pool
|
15
14
|
email:
|
@@ -27,33 +26,26 @@ files:
|
|
27
26
|
- test/gene_pool_test.rb
|
28
27
|
homepage: http://github.com/bpardee/gene_pool
|
29
28
|
licenses: []
|
29
|
+
metadata: {}
|
30
30
|
post_install_message:
|
31
31
|
rdoc_options: []
|
32
32
|
require_paths:
|
33
33
|
- lib
|
34
34
|
required_ruby_version: !ruby/object:Gem::Requirement
|
35
|
-
none: false
|
36
35
|
requirements:
|
37
|
-
- -
|
36
|
+
- - '>='
|
38
37
|
- !ruby/object:Gem::Version
|
39
38
|
version: '0'
|
40
|
-
segments:
|
41
|
-
- 0
|
42
|
-
hash: 102611247716920126
|
43
39
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
44
|
-
none: false
|
45
40
|
requirements:
|
46
|
-
- -
|
41
|
+
- - '>='
|
47
42
|
- !ruby/object:Gem::Version
|
48
43
|
version: '0'
|
49
|
-
segments:
|
50
|
-
- 0
|
51
|
-
hash: 102611247716920126
|
52
44
|
requirements: []
|
53
45
|
rubyforge_project:
|
54
|
-
rubygems_version:
|
46
|
+
rubygems_version: 2.0.3
|
55
47
|
signing_key:
|
56
|
-
specification_version:
|
48
|
+
specification_version: 4
|
57
49
|
summary: Generic pooling library for creating a connection pool
|
58
50
|
test_files:
|
59
51
|
- test/gene_pool_test.rb
|