async-container 0.27.2 → 0.27.3

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: 7d43fc927cb1564c1ed256976873b66245386fe54d11467935184c1f38da9d96
4
- data.tar.gz: 3738e9b3009bd87388fe23c34085d99a4ba384fe8ef274465ec732a8398f6b7b
3
+ metadata.gz: a8429de04372759748416b6b4e52a99ea6f7e89702f46d988d25301f958ca877
4
+ data.tar.gz: c24245f1fe1228f61418717be4f3096503682bfe4e3b12b2bfb1272a89e0f16e
5
5
  SHA512:
6
- metadata.gz: 14700cf9cb8952affd49569383348715fa357660b809f033a1a0d345a03f3b16145ec868b07022df1bece5224008a49ce78441d86113ef18c94530247fadf104
7
- data.tar.gz: 7665c5a66280b04bd835e9708e81fff08ab5116ab07886fae1aa3c3b155bef6011167d10bcdb63b08c3a877d5df795dd3901740a0e46ac0a433ff7cf024feac1
6
+ metadata.gz: df4d5a6c2a9c24fa7a054deda82445653690b7e51bb6828921b703ae77debb20eec636d2db962990501263a33482695e9d05eeb9170c1d72243bfd5f60d5d2a1
7
+ data.tar.gz: 972c007d20d6f023c8fea9f162009a37af2449947ff502e2e9af7041c025991726aafc0f2a19bef10be02d1c9612a99e1bf04d9612752cdfbf8d839de3ca9d37
checksums.yaml.gz.sig CHANGED
Binary file
@@ -260,7 +260,6 @@ module Async
260
260
  end
261
261
  end
262
262
 
263
-
264
263
  # Start a named child process and execute the provided block in it.
265
264
  # @parameter name [String] The name (title) of the child process.
266
265
  # @parameter block [Proc] The block to execute in the child process.
@@ -179,10 +179,13 @@ module Async
179
179
 
180
180
  fiber do
181
181
  while @running
182
- child = self.start(name, &block)
182
+ Console.info(self, "Starting child...", child: {key: key, name: name, restart: restart, health_check_timeout: health_check_timeout}, statistics: @statistics)
183
183
 
184
+ child = self.start(name, &block)
184
185
  state = insert(key, child)
185
186
 
187
+ Console.info(self, "Started child.", child: child, spawn: {key: key, restart: restart, health_check_timeout: health_check_timeout}, statistics: @statistics)
188
+
186
189
  # If a health check is specified, we will monitor the child process and terminate it if it does not update its state within the specified time.
187
190
  if health_check_timeout
188
191
  age_clock = state[:age] = Clock.start
@@ -183,7 +183,7 @@ module Async
183
183
  self.wait_for_exit(clock, interrupt_timeout)
184
184
  end
185
185
 
186
- if terminate_timeout
186
+ if terminate_timeout and self.any?
187
187
  clock = Async::Clock.start
188
188
 
189
189
  # If the children are still running, terminate them:
@@ -231,8 +231,8 @@ module Async
231
231
  protected
232
232
 
233
233
  def wait_for_children(duration = nil)
234
- # This log is a big noisy and doesn't really provide a lot of useful information.
235
- # Console.debug(self, "Waiting for children...", duration: duration, running: @running)
234
+ # This log is a bit noisy and doesn't really provide a lot of useful information:
235
+ Console.debug(self, "Waiting for children...", duration: duration, running: @running)
236
236
 
237
237
  unless @running.empty?
238
238
  # Maybe consider using a proper event loop here:
@@ -56,6 +56,24 @@ module Async
56
56
  @restarts += other.restarts
57
57
  @failures += other.failures
58
58
  end
59
+
60
+ # Generate a hash representation of the statistics.
61
+ #
62
+ # @returns [Hash] The statistics as a hash.
63
+ def as_json(...)
64
+ {
65
+ spawns: @spawns,
66
+ restarts: @restarts,
67
+ failures: @failures,
68
+ }
69
+ end
70
+
71
+ # Generate a JSON representation of the statistics.
72
+ #
73
+ # @returns [String] The statistics as JSON.
74
+ def to_json(...)
75
+ as_json.to_json(...)
76
+ end
59
77
  end
60
78
  end
61
79
  end
@@ -5,6 +5,6 @@
5
5
 
6
6
  module Async
7
7
  module Container
8
- VERSION = "0.27.2"
8
+ VERSION = "0.27.3"
9
9
  end
10
10
  end
data/readme.md CHANGED
@@ -26,6 +26,11 @@ 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/releases/index) for all releases.
28
28
 
29
+ ### v0.27.3
30
+
31
+ - Add log for starting child, including container statistics.
32
+ - Don't try to (log) "terminate 0 child processes" if there are none.
33
+
29
34
  ### v0.27.2
30
35
 
31
36
  - More logging, especially around failure cases.
@@ -64,12 +69,6 @@ Please see the [project releases](https://socketry.github.io/async-container/rel
64
69
  - Fix compatibility between <code class="language-ruby">Async::Container::Hybrid</code> and the health check.
65
70
  - <code class="language-ruby">Async::Container::Generic\#initialize</code> passes unused arguments through to <code class="language-ruby">Async::Container::Group</code>.
66
71
 
67
- ### v0.20.0
68
-
69
- - Improve container signal handling reliability by using `Thread.handle_interrupt` except at known safe points.
70
- - Improved logging when child process fails and container startup.
71
- - [Add `health_check_timeout` for detecting hung processes.](https://socketry.github.io/async-container/releases/index#add-health_check_timeout-for-detecting-hung-processes.)
72
-
73
72
  ## Contributing
74
73
 
75
74
  We welcome contributions to this project.
data/releases.md CHANGED
@@ -1,5 +1,10 @@
1
1
  # Releases
2
2
 
3
+ ## v0.27.3
4
+
5
+ - Add log for starting child, including container statistics.
6
+ - Don't try to (log) "terminate 0 child processes" if there are none.
7
+
3
8
  ## v0.27.2
4
9
 
5
10
  - More logging, especially around failure cases.
data.tar.gz.sig CHANGED
Binary file
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: async-container
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.27.2
4
+ version: 0.27.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Samuel Williams
metadata.gz.sig CHANGED
Binary file