async-container 0.20.0 → 0.20.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- checksums.yaml.gz.sig +0 -0
- data/lib/async/container/generic.rb +3 -1
- data/lib/async/container/hybrid.rb +4 -2
- data/lib/async/container/version.rb +1 -1
- data/readme.md +18 -1
- data/releases.md +42 -1
- data.tar.gz.sig +0 -0
- metadata +2 -2
- 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: 2435dd48259ab4b6bbad01780c21dc91bdf2946485f1dd682c8388b9ee68410d
|
4
|
+
data.tar.gz: c8e3564e5c889f469658eb044444bc6884575090ed38e73f07bcffdfe893f823
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: fa56a0207d1bab96685c25ca8f3617a5e5aefeb673998d836780baf75e1ff9ee9618ac4e506f893de206f425277a7abb0dc12f748850d59e037f5f155763b9d9
|
7
|
+
data.tar.gz: 1198eaa52f0ea7dfe3b411c1e6cf6866f720f9aa4b5b1913fee2fbb535144115b4e2e3e21e313fa01faa64e724e7e786e32732c0889d2c8601c8ccce72dfe967
|
checksums.yaml.gz.sig
CHANGED
Binary file
|
@@ -39,7 +39,7 @@ module Async
|
|
39
39
|
UNNAMED = "Unnamed"
|
40
40
|
|
41
41
|
def initialize(**options)
|
42
|
-
@group = Group.new
|
42
|
+
@group = Group.new(**options)
|
43
43
|
@running = true
|
44
44
|
|
45
45
|
@state = {}
|
@@ -48,8 +48,10 @@ module Async
|
|
48
48
|
@keyed = {}
|
49
49
|
end
|
50
50
|
|
51
|
+
# @attribute [Group] The group of running children instances.
|
51
52
|
attr :group
|
52
53
|
|
54
|
+
# @attribute [Hash(Child, Hash)] The state of each child instance.
|
53
55
|
attr :state
|
54
56
|
|
55
57
|
# A human readable representation of the container.
|
@@ -15,7 +15,8 @@ module Async
|
|
15
15
|
# @parameter count [Integer] The number of instances to start.
|
16
16
|
# @parameter forks [Integer] The number of processes to fork.
|
17
17
|
# @parameter threads [Integer] the number of threads to start.
|
18
|
-
|
18
|
+
# @parameter health_check_timeout [Numeric] The timeout for health checks, in seconds. Passed into the child {Threaded} containers.
|
19
|
+
def run(count: nil, forks: nil, threads: nil, health_check_timeout: nil, **options, &block)
|
19
20
|
processor_count = Container.processor_count
|
20
21
|
count ||= processor_count ** 2
|
21
22
|
forks ||= [processor_count, count].min
|
@@ -25,7 +26,7 @@ module Async
|
|
25
26
|
self.spawn(**options) do |instance|
|
26
27
|
container = Threaded.new
|
27
28
|
|
28
|
-
container.run(count: threads, **options, &block)
|
29
|
+
container.run(count: threads, health_check_timeout: health_check_timeout, **options, &block)
|
29
30
|
|
30
31
|
container.wait_until_ready
|
31
32
|
instance.ready!
|
@@ -34,6 +35,7 @@ module Async
|
|
34
35
|
rescue Async::Container::Terminate
|
35
36
|
# Stop it immediately:
|
36
37
|
container.stop(false)
|
38
|
+
raise
|
37
39
|
ensure
|
38
40
|
# Stop it gracefully (also code path for Interrupt):
|
39
41
|
container.stop
|
data/readme.md
CHANGED
@@ -14,7 +14,24 @@ Provides containers which implement parallelism for clients and servers.
|
|
14
14
|
|
15
15
|
## Usage
|
16
16
|
|
17
|
-
Please see the [project documentation](https://socketry.github.io/async-container/).
|
17
|
+
Please see the [project documentation](https://socketry.github.io/async-container/) for more details.
|
18
|
+
|
19
|
+
- [Getting Started](https://socketry.github.io/async-container/guides/getting-started/index) - This guide explains how to use `async-container` to build basic scalable systems.
|
20
|
+
|
21
|
+
## Releases
|
22
|
+
|
23
|
+
Please see the [project releases](https://socketry.github.io/async-container/releases/index) for all releases.
|
24
|
+
|
25
|
+
### v0.20.1
|
26
|
+
|
27
|
+
- Fix compatibility between <code class="language-ruby">Async::Container::Hybrid</code> and the health check.
|
28
|
+
- <code class="language-ruby">Async::Container::Generic\#initialize</code> passes unused arguments through to <code class="language-ruby">Async::Container::Group</code>.
|
29
|
+
|
30
|
+
### v0.20.0
|
31
|
+
|
32
|
+
- Improve container signal handling reliability by using `Thread.handle_interrupt` except at known safe points.
|
33
|
+
- Improved logging when child process fails and container startup.
|
34
|
+
- [Add `health_check_timeout` for detecting hung processes.](https://socketry.github.io/async-container/releases/index#add-health_check_timeout-for-detecting-hung-processes.)
|
18
35
|
|
19
36
|
## Contributing
|
20
37
|
|
data/releases.md
CHANGED
@@ -1,6 +1,47 @@
|
|
1
1
|
# Releases
|
2
2
|
|
3
|
-
##
|
3
|
+
## v0.20.1
|
4
|
+
|
5
|
+
- Fix compatibility between {ruby Async::Container::Hybrid} and the health check.
|
6
|
+
- {ruby Async::Container::Generic\#initialize} passes unused arguments through to {ruby Async::Container::Group}.
|
7
|
+
|
8
|
+
## v0.20.0
|
4
9
|
|
5
10
|
- Improve container signal handling reliability by using `Thread.handle_interrupt` except at known safe points.
|
6
11
|
- Improved logging when child process fails and container startup.
|
12
|
+
|
13
|
+
### Add `health_check_timeout` for detecting hung processes.
|
14
|
+
|
15
|
+
In order to detect hung processes, a `health_check_timeout` can be specified when spawning children workers. If the health check does not complete within the specified timeout, the child process is killed.
|
16
|
+
|
17
|
+
``` ruby
|
18
|
+
require "async/container"
|
19
|
+
|
20
|
+
container = Async::Container.new
|
21
|
+
|
22
|
+
container.run(count: 1, restart: true, health_check_timeout: 1) do |instance|
|
23
|
+
while true
|
24
|
+
# This example will fail sometimes:
|
25
|
+
sleep(0.5 + rand)
|
26
|
+
instance.ready!
|
27
|
+
end
|
28
|
+
end
|
29
|
+
|
30
|
+
container.wait
|
31
|
+
```
|
32
|
+
|
33
|
+
If the health check does not complete within the specified timeout, the child process is killed:
|
34
|
+
|
35
|
+
```
|
36
|
+
3.01s warn: Async::Container::Forked [oid=0x1340] [ec=0x1348] [pid=27100] [2025-02-20 13:24:55 +1300]
|
37
|
+
| Child failed health check!
|
38
|
+
| {
|
39
|
+
| "child": {
|
40
|
+
| "name": "Unnamed",
|
41
|
+
| "pid": 27101,
|
42
|
+
| "status": null
|
43
|
+
| },
|
44
|
+
| "age": 1.0612829999881797,
|
45
|
+
| "health_check_timeout": 1
|
46
|
+
| }
|
47
|
+
```
|
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.20.
|
4
|
+
version: 0.20.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Samuel Williams
|
@@ -40,7 +40,7 @@ cert_chain:
|
|
40
40
|
Q2K9NVun/S785AP05vKkXZEFYxqG6EW012U4oLcFl5MySFajYXRYbuUpH6AY+HP8
|
41
41
|
voD0MPg1DssDLKwXyt1eKD/+Fq0bFWhwVM/1XiAXL7lyYUyOq24KHgQ2Csg=
|
42
42
|
-----END CERTIFICATE-----
|
43
|
-
date: 2025-02-
|
43
|
+
date: 2025-02-20 00:00:00.000000000 Z
|
44
44
|
dependencies:
|
45
45
|
- !ruby/object:Gem::Dependency
|
46
46
|
name: async
|
metadata.gz.sig
CHANGED
Binary file
|