async-container 0.33.0 → 0.34.0

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: 540ced6fa47f3b7a289c62b426b58e9bf0269573eec8b886ce3a97748e2050fe
4
- data.tar.gz: 188bd801df86b8819989f679e66a4036761a77fe3f438e7121f065cb932c087a
3
+ metadata.gz: a0502d4a235533958f93fd6b4791479f056e42761394741af2427bfe027055bc
4
+ data.tar.gz: f4c07612adf5e21c1a7b5e86b0be8410e284f9606dad0daa5a4a3da9a94c7237
5
5
  SHA512:
6
- metadata.gz: 9da0dde241b6b11e5635e4dc899ea3112b64d789602f5d76a26d7596fad0d63596c8e3ffe7dd209a254ea3b8e27693d2345e9725d86bf3bcb5af5630dedd29bb
7
- data.tar.gz: 27db38943290ce92173ec0df1262f8803032f0068ad0ca17c5551d919f5a71d6f555bbc5be9b6d074df9bd23da94da8be042d13d24e4755b606087543167d93b
6
+ metadata.gz: 1a29ea78a23485e75e30a6e552bc8dcb18b3361844a8346e57eceec6d0db473747240f3c7818c1d6e6ceeb2cf59ac46d0115c11f13a1fded65dcfbfaef2d0d87
7
+ data.tar.gz: 26bbb632a633a15f18a32bd76ada51524e9671123e5d45f17721fb0a5eda22aa88d851f3b32c27272dfcf52279a2729fca909ba980839557ee50abab7426a3e7
checksums.yaml.gz.sig CHANGED
Binary file
@@ -47,7 +47,7 @@ module Async
47
47
  # @parameter options [Hash] Options passed to the {Group} instance.
48
48
  def initialize(policy: Policy::DEFAULT, **options)
49
49
  @group = Group.new(**options)
50
- @running = true
50
+ @stopping = false
51
51
 
52
52
  @state = {}
53
53
 
@@ -97,6 +97,12 @@ module Async
97
97
  @group.running?
98
98
  end
99
99
 
100
+ # Whether the container is currently stopping.
101
+ # @returns [Boolean]
102
+ def stopping?
103
+ @stopping
104
+ end
105
+
100
106
  # Sleep until some state change occurs or the specified duration elapses.
101
107
  #
102
108
  # @parameter duration [Numeric] the maximum amount of time to sleep for.
@@ -147,8 +153,13 @@ module Async
147
153
  # Stop the children instances.
148
154
  # @parameter timeout [Boolean | Numeric] Whether to stop gracefully, or a specific timeout.
149
155
  def stop(timeout = true)
156
+ if @stopping
157
+ Console.warn(self, "Container is already stopping!")
158
+ return
159
+ end
160
+
150
161
  Console.info(self, "Stopping container...", timeout: timeout)
151
- @running = false
162
+ @stopping = true
152
163
  @group.stop(timeout)
153
164
 
154
165
  if @group.running?
@@ -160,7 +171,7 @@ module Async
160
171
  Console.error(self, "Error while stopping container!", exception: error)
161
172
  raise
162
173
  ensure
163
- @running = true
174
+ @stopping = false
164
175
  end
165
176
 
166
177
  protected def health_check_failed(child, age_clock, health_check_timeout)
@@ -206,7 +217,7 @@ module Async
206
217
  @statistics.spawn!
207
218
 
208
219
  fiber do
209
- while @running
220
+ until @stopping
210
221
  Console.debug(self, "Starting child...", child: {key: key, name: name, restart: restart, health_check_timeout: health_check_timeout}, statistics: @statistics)
211
222
 
212
223
  child = self.start(name, &block)
@@ -257,16 +268,16 @@ module Async
257
268
  end
258
269
  end
259
270
  rescue => error
260
- Console.error(self, "Error during child process management!", exception: error, running: @running)
271
+ Console.error(self, "Error during child process management!", exception: error, stopping: @stopping)
261
272
  ensure
262
273
  delete(key, child)
263
274
  end
264
275
 
265
276
  if status&.success?
266
- Console.debug(self, "Child exited successfully.", status: status, running: @running)
277
+ Console.debug(self, "Child exited successfully.", status: status, stopping: @stopping)
267
278
  else
268
279
  @statistics.failure!
269
- Console.error(self, "Child exited with error!", status: status, running: @running)
280
+ Console.error(self, "Child exited with error!", status: status, stopping: @stopping)
270
281
  end
271
282
 
272
283
  # Notify policy of exit (after statistics are updated):
@@ -276,7 +287,7 @@ module Async
276
287
  Console.error(self, "Policy error in child_exit!", exception: error)
277
288
  end
278
289
 
279
- if restart && @running
290
+ if restart && !@stopping
280
291
  @statistics.restart!
281
292
  else
282
293
  break
@@ -5,6 +5,6 @@
5
5
 
6
6
  module Async
7
7
  module Container
8
- VERSION = "0.33.0"
8
+ VERSION = "0.34.0"
9
9
  end
10
10
  end
data/readme.md CHANGED
@@ -28,6 +28,10 @@ Please see the [project documentation](https://socketry.github.io/async-containe
28
28
 
29
29
  Please see the [project releases](https://socketry.github.io/async-container/releases/index) for all releases.
30
30
 
31
+ ### v0.34.0
32
+
33
+ - Add `Async::Container::Generic#stopping?` so that policies can more accurately track the state of the container.
34
+
31
35
  ### v0.33.0
32
36
 
33
37
  - Add `Policy#make_statistics` to allow policies to customize statistics initialization.
@@ -69,11 +73,6 @@ Please see the [project releases](https://socketry.github.io/async-container/rel
69
73
 
70
74
  - Fix race condition where `wait_for` could modify `@running` while it was being iterated over (`each_value`) during health checks.
71
75
 
72
- ### v0.27.3
73
-
74
- - Add log for starting child, including container statistics.
75
- - Don't try to (log) "terminate 0 child processes" if there are none.
76
-
77
76
  ## Contributing
78
77
 
79
78
  We welcome contributions to this project.
data/releases.md CHANGED
@@ -1,5 +1,9 @@
1
1
  # Releases
2
2
 
3
+ ## v0.34.0
4
+
5
+ - Add `Async::Container::Generic#stopping?` so that policies can more accurately track the state of the container.
6
+
3
7
  ## v0.33.0
4
8
 
5
9
  - Add `Policy#make_statistics` to allow policies to customize statistics initialization.
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.33.0
4
+ version: 0.34.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Samuel Williams
metadata.gz.sig CHANGED
Binary file