with_connection 0.1.3 → 0.1.4

Sign up to get free protection for your applications and to get access to all the features.
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.1.3
1
+ 0.1.4
@@ -35,6 +35,33 @@ module WithConnection
35
35
  release_connection
36
36
  end
37
37
 
38
+ # copied directly from the ActiveRecord just so I could change the error message
39
+ def checkout
40
+ # Checkout an available connection
41
+ @connection_mutex.synchronize do
42
+ loop do
43
+ conn = if @checked_out.size < @connections.size
44
+ checkout_existing_connection
45
+ elsif @connections.size < @size
46
+ checkout_new_connection
47
+ end
48
+ return conn if conn
49
+
50
+ @queue.wait(@timeout)
51
+
52
+ if(@checked_out.size < @connections.size)
53
+ next
54
+ else
55
+ clear_stale_cached_connections!
56
+ if @size == @checked_out.size
57
+ raise ConnectionTimeoutError, "could not obtain a #{name} connection#{" within #{@timeout} seconds" if @timeout}. The max pool size is currently #{@size}; consider increasing it."
58
+ end
59
+ end
60
+
61
+ end
62
+ end
63
+ end
64
+
38
65
  private
39
66
  def new_connection
40
67
  spec.adapter_method.call spec.config
@@ -5,11 +5,11 @@
5
5
 
6
6
  Gem::Specification.new do |s|
7
7
  s.name = "with_connection"
8
- s.version = "0.1.3"
8
+ s.version = "0.1.4"
9
9
 
10
10
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
11
  s.authors = ["Doug Youch"]
12
- s.date = "2013-06-05"
12
+ s.date = "2013-06-06"
13
13
  s.description = "Uses active record connection pool logic with the fiber_patch"
14
14
  s.email = "doug@sessionm.com"
15
15
  s.extra_rdoc_files = [
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: with_connection
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.3
4
+ version: 0.1.4
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2013-06-05 00:00:00.000000000 Z
12
+ date: 2013-06-06 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: rails
@@ -112,7 +112,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
112
112
  version: '0'
113
113
  segments:
114
114
  - 0
115
- hash: 3405355780874312371
115
+ hash: -1949160586113175255
116
116
  required_rubygems_version: !ruby/object:Gem::Requirement
117
117
  none: false
118
118
  requirements: