with_connection 0.1.19 → 0.1.20
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.
|
1
|
+
0.1.20
|
@@ -16,9 +16,17 @@ module WithConnection
|
|
16
16
|
!! @reserved_connections[current_connection_id]
|
17
17
|
end
|
18
18
|
|
19
|
-
def
|
19
|
+
def with_connection(key=nil, read_write=nil)
|
20
|
+
connection_id = current_connection_id
|
21
|
+
fresh_connection = true unless @reserved_connections[connection_id]
|
22
|
+
yield connection
|
23
|
+
ensure
|
24
|
+
release_connection(connection_id) if fresh_connection
|
25
|
+
end
|
26
|
+
|
27
|
+
def with_connection_with_debug(key=nil, read_write=nil, &block)
|
20
28
|
@using_with_connection = true
|
21
|
-
with_connection_without_debug(&block).tap { @using_with_connection = false }
|
29
|
+
with_connection_without_debug(key, read_write, &block).tap { @using_with_connection = false }
|
22
30
|
end
|
23
31
|
alias_method_chain :with_connection, :debug
|
24
32
|
|
@@ -8,17 +8,18 @@ module WithConnection
|
|
8
8
|
@key_algo = key_algo
|
9
9
|
end
|
10
10
|
|
11
|
-
def with_connection(key=nil, &block)
|
12
|
-
local_current[:with_connection_ranged_connection_pool] = pool_for_key(key)
|
13
|
-
local_current[:with_connection_ranged_connection_pool].with_connection(&block)
|
11
|
+
def with_connection(key=nil, read_write=nil, &block)
|
12
|
+
local_current[:with_connection_ranged_connection_pool] = pool_for_key(key, read_write)
|
13
|
+
local_current[:with_connection_ranged_connection_pool].with_connection(key, read_write, &block)
|
14
|
+
ensure
|
15
|
+
local_current[:with_connection_ranged_connection_pool] = nil
|
14
16
|
end
|
15
17
|
|
16
18
|
def connection
|
17
|
-
local_current[:with_connection_ranged_connection_pool]
|
18
|
-
local_current[:with_connection_ranged_connection_pool].connection
|
19
|
+
local_current[:with_connection_ranged_connection_pool].try(:connection) || @default_pool.connection
|
19
20
|
end
|
20
21
|
|
21
|
-
def pool_for_key(key)
|
22
|
+
def pool_for_key(key, read_write)
|
22
23
|
key = self.key_algo.call(key) if key
|
23
24
|
key.nil? ?
|
24
25
|
@default_pool :
|
data/with_connection.gemspec
CHANGED
@@ -5,11 +5,11 @@
|
|
5
5
|
|
6
6
|
Gem::Specification.new do |s|
|
7
7
|
s.name = "with_connection"
|
8
|
-
s.version = "0.1.
|
8
|
+
s.version = "0.1.20"
|
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-
|
12
|
+
s.date = "2013-06-24"
|
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.
|
4
|
+
version: 0.1.20
|
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-
|
12
|
+
date: 2013-06-24 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: rails
|
@@ -115,7 +115,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
115
115
|
version: '0'
|
116
116
|
segments:
|
117
117
|
- 0
|
118
|
-
hash: -
|
118
|
+
hash: -2152765510823986754
|
119
119
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
120
120
|
none: false
|
121
121
|
requirements:
|