em-pg-client 0.2.0.pre.1 → 0.2.0.pre.2
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.
- data/HISTORY.rdoc +8 -1
- data/em-pg-client.gemspec +1 -1
- data/lib/pg/em.rb +24 -11
- metadata +1 -1
data/HISTORY.rdoc
CHANGED
@@ -1,10 +1,17 @@
|
|
1
|
-
|
1
|
+
0.2.0.pre.2
|
2
|
+
- errors from consume_input fails deferrable
|
3
|
+
- query_timeout now measures only network response timeout,
|
4
|
+
so it's not fired for large datasets
|
5
|
+
|
6
|
+
0.2.0.pre.1
|
7
|
+
- added query_timeout feature for async query commands
|
2
8
|
- added connect_timeout property with for async connect/reset
|
3
9
|
- fix: async_autoreconnect for tcp/ip connections
|
4
10
|
- fix: async_* does not raise errors; errors handled by deferrable
|
5
11
|
- rework async_autoreconnect in fully async manner
|
6
12
|
- added async_connect() and #async_reset()
|
7
13
|
- API change: on_reconnect -> on_autoreconnect
|
14
|
+
|
8
15
|
0.1.1
|
9
16
|
- added on_reconnect callback
|
10
17
|
- docs updated
|
data/em-pg-client.gemspec
CHANGED
data/lib/pg/em.rb
CHANGED
@@ -135,31 +135,44 @@ module PG
|
|
135
135
|
@deferrable = deferrable
|
136
136
|
@send_proc = send_proc
|
137
137
|
if (timeout = client.query_timeout) > 0
|
138
|
-
@
|
138
|
+
@notify_timestamp = Time.now
|
139
|
+
setup_timer timeout
|
140
|
+
else
|
141
|
+
@timer = nil
|
142
|
+
end
|
143
|
+
end
|
144
|
+
|
145
|
+
def setup_timer(timeout, adjustment = 0)
|
146
|
+
@timer = ::EM::Timer.new(timeout - adjustment) do
|
147
|
+
if (last_interval = Time.now - @notify_timestamp) >= timeout
|
139
148
|
detach
|
140
149
|
@client.async_command_aborted = true
|
141
150
|
IO.for_fd(@client.socket).close # break connection now (hack)
|
142
151
|
@deferrable.protect do
|
143
152
|
raise PG::Error, "query timeout expired (async)"
|
144
153
|
end
|
154
|
+
else
|
155
|
+
setup_timer timeout, last_interval
|
145
156
|
end
|
146
157
|
end
|
147
158
|
end
|
148
159
|
|
149
160
|
def notify_readable
|
161
|
+
@notify_timestamp = Time.now if @timer
|
150
162
|
@client.consume_input
|
151
|
-
|
152
|
-
|
153
|
-
detach
|
154
|
-
begin
|
155
|
-
result = @client.get_last_result
|
156
|
-
rescue PG::Error => e
|
157
|
-
@client.async_autoreconnect!(@deferrable, e, &@send_proc)
|
158
|
-
rescue Exception => e
|
159
|
-
@deferrable.fail(e)
|
163
|
+
result = if @client.is_busy
|
164
|
+
false
|
160
165
|
else
|
161
|
-
@
|
166
|
+
@timer.cancel if @timer
|
167
|
+
detach
|
168
|
+
@client.get_last_result
|
162
169
|
end
|
170
|
+
rescue PG::Error => e
|
171
|
+
@client.async_autoreconnect!(@deferrable, e, &@send_proc)
|
172
|
+
rescue Exception => e
|
173
|
+
@deferrable.fail(e)
|
174
|
+
else
|
175
|
+
@deferrable.succeed(result) unless result == false
|
163
176
|
end
|
164
177
|
end
|
165
178
|
|