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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 1b9684c9b4ef621c8b92411d251478b9751cc901e251fa1b35c3fca92af18763
4
- data.tar.gz: 5e9f9a25b01f4de9c160aa194acd2a3467215d09ccbbdfbac178c2bb1f278e58
3
+ metadata.gz: b997fac3e6c645d7740f0099a3543d27d983a86057a4cde23a85254d30a2d32f
4
+ data.tar.gz: 83f0ce708ade60a56158e615d6222788444bb2dfbc980cd6438a93dc6ef3c18b
5
5
  SHA512:
6
- metadata.gz: 7fa18caa63bb5dff847b3640c63ca5c2109a3003537bf36cf8ac2947d560a8c0dc5d201b79e98c789e991db415fb2b07aa2c8a9cf94f556f2d932d68d4044dd4
7
- data.tar.gz: 235f540925cc1ea12f1f2ef89df5cfacca213e56c4a0b39514f610a92e93e7de995e087842eb827936daa954802631ced0f5ca89ae22f7441c69763f10d7bc6b
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
- # Response to a call:
295
+ # Enqueue the response for the call:
283
296
  call.push(**message)
284
297
  elsif message.key?(:do)
285
- # Incoming call:
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
- # Likely a response to a timed-out call, ignore it:
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
@@ -9,7 +9,7 @@ module Async
9
9
  module Container
10
10
  # @namespace
11
11
  module Supervisor
12
- VERSION = "0.9.0"
12
+ VERSION = "0.9.1"
13
13
  end
14
14
  end
15
15
  end
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
@@ -1,5 +1,9 @@
1
1
  # Releases
2
2
 
3
+ ## v0.9.1
4
+
5
+ - Close `Call` queue if asynchronous call fails during dispatch - further messages will fail with `ClosedQueueError`.
6
+
3
7
  ## v0.9.0
4
8
 
5
9
  - Better handling of write failures in `Connection::Call.dispatch`, ensuring we don't leak calls.
data.tar.gz.sig CHANGED
Binary file
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: async-container-supervisor
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.9.0
4
+ version: 0.9.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Samuel Williams
metadata.gz.sig CHANGED
Binary file