em-sequel-async 0.1.1 → 0.1.2
Sign up to get free protection for your applications and to get access to all the features.
- data/VERSION +1 -1
- data/em-sequel-async.gemspec +2 -2
- data/lib/em-sequel-async/mysql.rb +43 -4
- metadata +2 -2
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.1.
|
1
|
+
0.1.2
|
data/em-sequel-async.gemspec
CHANGED
@@ -5,11 +5,11 @@
|
|
5
5
|
|
6
6
|
Gem::Specification.new do |s|
|
7
7
|
s.name = "em-sequel-async"
|
8
|
-
s.version = "0.1.
|
8
|
+
s.version = "0.1.2"
|
9
9
|
|
10
10
|
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
11
11
|
s.authors = ["Scott Tadman"]
|
12
|
-
s.date = "2012-11-
|
12
|
+
s.date = "2012-11-22"
|
13
13
|
s.description = "Implements a number of asynchronous helper methods for Sequel"
|
14
14
|
s.email = "scott@twg.ca"
|
15
15
|
s.extra_rdoc_files = [
|
@@ -94,6 +94,11 @@ class EmSequelAsync::Mysql
|
|
94
94
|
end
|
95
95
|
end
|
96
96
|
|
97
|
+
def remove(connection)
|
98
|
+
@connections.delete(connection)
|
99
|
+
@connections_active.delete(connection)
|
100
|
+
end
|
101
|
+
|
97
102
|
def delegate_query(connection, query, callback)
|
98
103
|
@connections[connection] = [ query, callback ]
|
99
104
|
|
@@ -108,12 +113,38 @@ class EmSequelAsync::Mysql
|
|
108
113
|
self.add(connection)
|
109
114
|
end
|
110
115
|
deferrable.errback do |err|
|
111
|
-
|
112
|
-
log(:error, err.backtrace)
|
116
|
+
handled = false
|
113
117
|
|
114
|
-
|
118
|
+
case (err)
|
119
|
+
when Mysql2::Error
|
120
|
+
case (err.message)
|
121
|
+
when /^Deadlock/i
|
122
|
+
self.delegate_query(connection, query, callback)
|
115
123
|
|
116
|
-
|
124
|
+
handled = true
|
125
|
+
when /Duplicate entry/i
|
126
|
+
callback and callback.call(nil, (Time.now - start).to_f, connection, err)
|
127
|
+
|
128
|
+
self.add(connection)
|
129
|
+
|
130
|
+
handled = true
|
131
|
+
when /MySQL server has gone away|Lost connection/i
|
132
|
+
@query_queue << [ query, callback ]
|
133
|
+
|
134
|
+
self.remove(connection)
|
135
|
+
|
136
|
+
handled = true
|
137
|
+
end
|
138
|
+
end
|
139
|
+
|
140
|
+
unless (handled)
|
141
|
+
log(:error, "(%.6fs) [ERR] %s (%s: %s)" % [ Time.now - start, query, err.class, err ])
|
142
|
+
log(:error, err.backtrace)
|
143
|
+
|
144
|
+
callback and callback.call(false, (Time.now - start).to_f, connection, err)
|
145
|
+
|
146
|
+
self.add(connection)
|
147
|
+
end
|
117
148
|
end
|
118
149
|
end
|
119
150
|
|
@@ -127,6 +158,14 @@ class EmSequelAsync::Mysql
|
|
127
158
|
@connections_active[connection] = true
|
128
159
|
|
129
160
|
connection
|
161
|
+
|
162
|
+
rescue Mysql2::Error => err
|
163
|
+
case (err.message)
|
164
|
+
when /Too many connections/i
|
165
|
+
return
|
166
|
+
else
|
167
|
+
raise err
|
168
|
+
end
|
130
169
|
end
|
131
170
|
|
132
171
|
def query(query, callback = nil, &block)
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: em-sequel-async
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.2
|
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: 2012-11-
|
12
|
+
date: 2012-11-22 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: sequel
|