async-container 0.28.0 → 0.29.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: b600b0cd62cf8c6ba832a6022ba2e2aeca1709264b696277fe11055074d36ea3
4
- data.tar.gz: 456e1cfb343619036dfb70ac693f302b3a0dc61c0a1e3d698544c5632fabb7f8
3
+ metadata.gz: 3d92a0a4336ea40b938ef0b8b54c7dd695f8814df486fd7d80064dbb6a131722
4
+ data.tar.gz: f944972f872903ce0552b72e506888f84ad9dde40c980cbd4893f59019604eef
5
5
  SHA512:
6
- metadata.gz: e72593aa02a1ad84c7223d178cf6f89bd9dbd8387539a0c77c50bcec9ac03a118a978cc3e87544b850cdeebb6a1d3925ddcee01e3866129cd8a395aae586f056
7
- data.tar.gz: 24e370fbd183a791179cb7fbd6089e513bbdf1767af8fc955cf3e6690c937f075a2cb255915172bb46d1dc08d6995595deaf3e6d3fc39cf643a558d21e14bd7d
6
+ metadata.gz: 8ae6df190c3ea6e654604bc545f07e1b76af03c3ff02dd236997a9c09035c482b060244ba349d831f74138338d72be307b214c292915185035b38de173eb6b98
7
+ data.tar.gz: 4f7a6913143f38ec54a9f727f3bf1c738d2f7f79bd777a90fd4302689ae0c67c15faf528f1a171387a35a07cd9e168101d928ffe062749d5f0ab71e6b0e1a05f
checksums.yaml.gz.sig CHANGED
Binary file
@@ -91,7 +91,8 @@ module Async
91
91
  @group.running?
92
92
  end
93
93
 
94
- # Sleep until some state change occurs.
94
+ # Sleep until some state change occurs or the specified duration elapses.
95
+ #
95
96
  # @parameter duration [Numeric] the maximum amount of time to sleep for.
96
97
  def sleep(duration = nil)
97
98
  @group.sleep(duration)
@@ -140,7 +141,7 @@ module Async
140
141
  # Stop the children instances.
141
142
  # @parameter timeout [Boolean | Numeric] Whether to stop gracefully, or a specific timeout.
142
143
  def stop(timeout = true)
143
- Console.info(self, "Stopping container...", timeout: timeout, caller: caller_locations)
144
+ Console.debug(self, "Stopping container...", timeout: timeout)
144
145
  @running = false
145
146
  @group.stop(timeout)
146
147
 
@@ -1,7 +1,7 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  # Released under the MIT License.
4
- # Copyright, 2020-2025, by Samuel Williams.
4
+ # Copyright, 2020-2026, by Samuel Williams.
5
5
 
6
6
  module Async
7
7
  module Container
@@ -17,6 +17,12 @@ module Async
17
17
  send(ready: true, **message)
18
18
  end
19
19
 
20
+ # Notify the parent controller that the child is healthy.
21
+ # @parameters message [Hash] Additional details to send with the message.
22
+ def healthy!(**message)
23
+ send(healthy: true, **message)
24
+ end
25
+
20
26
  # Notify the parent controller that the child is reloading.
21
27
  # @parameters message [Hash] Additional details to send with the message.
22
28
  def reloading!(**message)
@@ -1,12 +1,13 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  # Released under the MIT License.
4
- # Copyright, 2020-2025, by Samuel Williams.
4
+ # Copyright, 2020-2026, by Samuel Williams.
5
5
  # Copyright, 2020, by Olle Jonsson.
6
6
 
7
7
  require "tmpdir"
8
8
  require "socket"
9
9
  require "securerandom"
10
+ require "set"
10
11
 
11
12
  module Async
12
13
  module Container
@@ -15,6 +16,20 @@ module Async
15
16
  class Server
16
17
  MAXIMUM_MESSAGE_SIZE = 4096
17
18
 
19
+ # Fields from the systemd sd_notify protocol that use "0"/"1" for boolean values.
20
+ # See: https://www.freedesktop.org/software/systemd/man/sd_notify.html
21
+ BOOLEAN_FIELDS = Set[
22
+ :ready,
23
+ :reloading,
24
+ :stopping,
25
+ :fdstore,
26
+ :fdstoreremove,
27
+ :fdpoll,
28
+ :barrier,
29
+ :watchdog, # Note: also accepts "trigger" as a string value.
30
+ :healthy, # Extension: not in standard systemd protocol.
31
+ ].freeze
32
+
18
33
  # Parse a message, according to the `sd_notify` protocol.
19
34
  #
20
35
  # @parameter message [String] The message to parse.
@@ -29,11 +44,15 @@ module Async
29
44
 
30
45
  key = key.downcase.to_sym
31
46
 
32
- if value == "0"
33
- value = false
34
- elsif value == "1"
35
- value = true
47
+ if BOOLEAN_FIELDS.include?(key)
48
+ # Convert "0"/"1" to boolean for known systemd boolean fields:
49
+ if value == "0"
50
+ value = false
51
+ elsif value == "1"
52
+ value = true
53
+ end
36
54
  elsif key == :errno and value =~ /\A\-?\d+\z/
55
+ # Convert errno to integer:
37
56
  value = Integer(value)
38
57
  end
39
58
 
@@ -1,10 +1,10 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  # Released under the MIT License.
4
- # Copyright, 2017-2025, by Samuel Williams.
4
+ # Copyright, 2017-2026, by Samuel Williams.
5
5
 
6
6
  module Async
7
7
  module Container
8
- VERSION = "0.28.0"
8
+ VERSION = "0.29.1"
9
9
  end
10
10
  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/releases/index) for all releases.
28
28
 
29
+ ### v0.29.0
30
+
31
+ - Introduce `Client#healthy!` for sending health check messages.
32
+
29
33
  ### v0.28.0
30
34
 
31
35
  - Add `startup_timeout` parameter to `spawn` and `run` methods for detecting processes that hang during startup and never become ready.
@@ -65,10 +69,6 @@ Please see the [project releases](https://socketry.github.io/async-container/rel
65
69
 
66
70
  - Introduce `async:container:notify:log:ready?` task for detecting process readiness.
67
71
 
68
- ### v0.24.0
69
-
70
- - Add support for health check failure metrics.
71
-
72
72
  ## Contributing
73
73
 
74
74
  We welcome contributions to this project.
data/releases.md CHANGED
@@ -1,5 +1,9 @@
1
1
  # Releases
2
2
 
3
+ ## v0.29.0
4
+
5
+ - Introduce `Client#healthy!` for sending health check messages.
6
+
3
7
  ## v0.28.0
4
8
 
5
9
  - Add `startup_timeout` parameter to `spawn` and `run` methods for detecting processes that hang during startup and never become ready.
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.28.0
4
+ version: 0.29.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Samuel Williams
metadata.gz.sig CHANGED
Binary file