async-container-supervisor 0.9.0 → 0.9.1
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.
- checksums.yaml +4 -4
- checksums.yaml.gz.sig +0 -0
- data/lib/async/container/supervisor/connection.rb +16 -3
- data/lib/async/container/supervisor/version.rb +1 -1
- data/readme.md +4 -0
- data/releases.md +4 -0
- data.tar.gz.sig +0 -0
- metadata +1 -1
- metadata.gz.sig +0 -0
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: b997fac3e6c645d7740f0099a3543d27d983a86057a4cde23a85254d30a2d32f
|
|
4
|
+
data.tar.gz: 83f0ce708ade60a56158e615d6222788444bb2dfbc980cd6438a93dc6ef3c18b
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: f6baf3ac944b425114dcb952da846b73a35fbf183ddb078c4b273015b1951a7a4658b2eba72088994fee6a4df81ff5f7c9faf79ccc4cae1433ec7a4080e8c362
|
|
7
|
+
data.tar.gz: 2069afe1a540bc4733d7a5e6ae0c4d0270787bd500a940b6131c31427b6f21f97d0e29911eda516887e745b33d4a37210e1f935089a07af62143620e8800b2e7
|
checksums.yaml.gz.sig
CHANGED
|
Binary file
|
|
@@ -147,10 +147,13 @@ module Async
|
|
|
147
147
|
def self.dispatch(connection, target, id, message)
|
|
148
148
|
Async do
|
|
149
149
|
call = self.new(connection, id, message)
|
|
150
|
+
# Track the call in the connection's calls hash:
|
|
150
151
|
connection.calls[id] = call
|
|
151
152
|
|
|
153
|
+
# Dispatch the call to the target (synchronously):
|
|
152
154
|
target.dispatch(call)
|
|
153
155
|
|
|
156
|
+
# Stream responses back to the connection (asynchronously):
|
|
154
157
|
while response = call.pop
|
|
155
158
|
connection.write(id: id, **response)
|
|
156
159
|
end
|
|
@@ -160,6 +163,9 @@ module Async
|
|
|
160
163
|
|
|
161
164
|
# If the queue is closed, we don't need to send a finished message:
|
|
162
165
|
unless call.closed?
|
|
166
|
+
# Ensure the call is closed, to prevent messages being buffered:
|
|
167
|
+
call.close
|
|
168
|
+
|
|
163
169
|
# If the above write failed, this is likely to fail too, and we can safely ignore it.
|
|
164
170
|
connection.write(id: id, finished: true) rescue nil
|
|
165
171
|
end
|
|
@@ -207,7 +213,11 @@ module Async
|
|
|
207
213
|
end
|
|
208
214
|
end
|
|
209
215
|
ensure
|
|
216
|
+
# Ensure the call is removed from the connection's calls hash, otherwise it will leak:
|
|
210
217
|
connection.calls.delete(id)
|
|
218
|
+
|
|
219
|
+
# Ensure the call is closed, so that `Call#pop` will return `nil`.
|
|
220
|
+
call.close
|
|
211
221
|
end
|
|
212
222
|
end
|
|
213
223
|
end
|
|
@@ -276,16 +286,19 @@ module Async
|
|
|
276
286
|
#
|
|
277
287
|
# @parameter target [Dispatchable] The target to dispatch calls to.
|
|
278
288
|
def run(target)
|
|
289
|
+
# Process incoming messages from the connection:
|
|
279
290
|
self.each do |message|
|
|
291
|
+
# If the message has an ID, it is a response to a call:
|
|
280
292
|
if id = message.delete(:id)
|
|
293
|
+
# Find the call in the connection's calls hash:
|
|
281
294
|
if call = @calls[id]
|
|
282
|
-
#
|
|
295
|
+
# Enqueue the response for the call:
|
|
283
296
|
call.push(**message)
|
|
284
297
|
elsif message.key?(:do)
|
|
285
|
-
#
|
|
298
|
+
# Otherwise, if we couldn't find an existing call, it must be a new call:
|
|
286
299
|
Call.dispatch(self, target, id, message)
|
|
287
300
|
else
|
|
288
|
-
#
|
|
301
|
+
# Finally, if none of the above, it is likely a response to a timed-out call, so ignore it:
|
|
289
302
|
Console.debug(self, "Ignoring message:", message)
|
|
290
303
|
end
|
|
291
304
|
else
|
data/readme.md
CHANGED
|
@@ -26,6 +26,10 @@ Please see the [project documentation](https://socketry.github.io/async-containe
|
|
|
26
26
|
|
|
27
27
|
Please see the [project releases](https://socketry.github.io/async-container-supervisor/releases/index) for all releases.
|
|
28
28
|
|
|
29
|
+
### v0.9.1
|
|
30
|
+
|
|
31
|
+
- Close `Call` queue if asynchronous call fails during dispatch - further messages will fail with `ClosedQueueError`.
|
|
32
|
+
|
|
29
33
|
### v0.9.0
|
|
30
34
|
|
|
31
35
|
- Better handling of write failures in `Connection::Call.dispatch`, ensuring we don't leak calls.
|
data/releases.md
CHANGED
data.tar.gz.sig
CHANGED
|
Binary file
|
metadata
CHANGED
metadata.gz.sig
CHANGED
|
Binary file
|