async-service 0.20.1 → 0.22.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 +4 -4
- checksums.yaml.gz.sig +0 -0
- data/bake/async/service/configuration.rb +30 -0
- data/bake/async/service/controller.rb +22 -0
- data/lib/async/service/managed/health_checker.rb +7 -11
- data/lib/async/service/managed/service.rb +3 -0
- data/lib/async/service/version.rb +1 -1
- data/readme.md +8 -9
- data/releases.md +8 -0
- data.tar.gz.sig +0 -0
- metadata +5 -3
- 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: b34c255ee7608b446acf8a57e86b876644f34eb21d5afa6b2a35d8f6235bb718
|
|
4
|
+
data.tar.gz: 66b3494d6bdfb347e1ae6b1440261754132a70fa903743f5d50dc19d636ef13e
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: bc3919f55bbf3221098522a47ecc4d744cdabc97f958d4b5d63dc8ed350c4f778b414acda577304a1a2b6493132abf01562f333a67bd84f348feab260d20c9ad
|
|
7
|
+
data.tar.gz: 9adf428ca9ddd8eb76aa0adcd67ab60268fa49bfe118d868b5fca6a75aa27749a4576f1f437f2e94855bcb2fd1013dd06ec4e8c4ec801b8c4cd99ddbbd77bf5d
|
checksums.yaml.gz.sig
CHANGED
|
Binary file
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
# Released under the MIT License.
|
|
4
|
+
# Copyright, 2024-2025, by Samuel Williams.
|
|
5
|
+
|
|
6
|
+
def initialize(context)
|
|
7
|
+
super
|
|
8
|
+
|
|
9
|
+
require "async/service/configuration"
|
|
10
|
+
|
|
11
|
+
@configuration = Async::Service::Configuration.new
|
|
12
|
+
end
|
|
13
|
+
|
|
14
|
+
attr :configuration
|
|
15
|
+
|
|
16
|
+
# Load the configuration from the given path.
|
|
17
|
+
# @parameter path [String] The path to the configuration file.
|
|
18
|
+
def load(path)
|
|
19
|
+
@configuration.load_file(path)
|
|
20
|
+
end
|
|
21
|
+
|
|
22
|
+
# List the available environments (all named environments).
|
|
23
|
+
def list
|
|
24
|
+
@configuration.environments.map(&:to_h)
|
|
25
|
+
end
|
|
26
|
+
|
|
27
|
+
# List the available services (those that define a service class).
|
|
28
|
+
def services
|
|
29
|
+
@configuration.services.map(&:to_h)
|
|
30
|
+
end
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
# Released under the MIT License.
|
|
4
|
+
# Copyright, 2024-2026, by Samuel Williams.
|
|
5
|
+
|
|
6
|
+
def initialize(context)
|
|
7
|
+
super
|
|
8
|
+
|
|
9
|
+
require "async/service/controller"
|
|
10
|
+
end
|
|
11
|
+
|
|
12
|
+
def run
|
|
13
|
+
controller.run
|
|
14
|
+
end
|
|
15
|
+
|
|
16
|
+
private
|
|
17
|
+
|
|
18
|
+
def controller
|
|
19
|
+
configuration = context.lookup("async:service:configuration").instance.configuration
|
|
20
|
+
|
|
21
|
+
return configuration.make_controller
|
|
22
|
+
end
|
|
@@ -10,32 +10,28 @@ module Async
|
|
|
10
10
|
module HealthChecker
|
|
11
11
|
# Start the health checker.
|
|
12
12
|
#
|
|
13
|
-
# If a timeout is specified, a transient child task will be scheduled
|
|
13
|
+
# If a timeout is specified, a transient child task will be scheduled which will mark the instance as healthy, sleep for half the health check duration (so that we guarantee that the health check runs in time), and then yield the instance if a block is given. This repeats indefinitely.
|
|
14
14
|
#
|
|
15
|
-
# If a timeout is not specified, the
|
|
15
|
+
# If a timeout is not specified, the instance is marked as healthy immediately and no task is created. Any block given is ignored.
|
|
16
16
|
#
|
|
17
17
|
# @parameter instance [Object] The service instance to check.
|
|
18
18
|
# @parameter timeout [Numeric] The timeout duration for the health check.
|
|
19
19
|
# @parameter parent [Async::Task] The parent task to run the health checker in.
|
|
20
|
-
# @yields {|instance| ...} If a block is given, it will be called with the service instance
|
|
20
|
+
# @yields {|instance| ...} If a block is given and a timeout is specified, it will be called with the service instance after each sleep interval.
|
|
21
21
|
def health_checker(instance, timeout = @evaluator.health_check_timeout, parent: Async::Task.current, &block)
|
|
22
22
|
if timeout
|
|
23
23
|
parent.async(transient: true) do
|
|
24
24
|
while true
|
|
25
|
-
if block_given?
|
|
26
|
-
yield(instance)
|
|
27
|
-
end
|
|
28
|
-
|
|
29
25
|
instance.healthy!
|
|
30
26
|
|
|
31
27
|
sleep(timeout / 2.0)
|
|
28
|
+
|
|
29
|
+
if block_given?
|
|
30
|
+
yield(instance)
|
|
31
|
+
end
|
|
32
32
|
end
|
|
33
33
|
end
|
|
34
34
|
else
|
|
35
|
-
if block_given?
|
|
36
|
-
yield(instance)
|
|
37
|
-
end
|
|
38
|
-
|
|
39
35
|
instance.healthy!
|
|
40
36
|
end
|
|
41
37
|
end
|
|
@@ -93,6 +93,7 @@ module Async
|
|
|
93
93
|
evaluator = self.environment.evaluator
|
|
94
94
|
server = nil
|
|
95
95
|
|
|
96
|
+
# If a health check timeout is configured, this block runs periodically to refresh the process title. Without a timeout there is no periodic timer, so the block is never called — the one-shot assignment below handles that case.
|
|
96
97
|
health_checker(instance, health_check_timeout) do
|
|
97
98
|
if server
|
|
98
99
|
instance.name = format_title(evaluator, server)
|
|
@@ -105,6 +106,8 @@ module Async
|
|
|
105
106
|
|
|
106
107
|
instance.status!("Running...")
|
|
107
108
|
server = run(instance, evaluator)
|
|
109
|
+
# Set the process title immediately once the server is available:
|
|
110
|
+
instance.name = format_title(evaluator, server)
|
|
108
111
|
emit_running(instance, clock)
|
|
109
112
|
|
|
110
113
|
instance.ready!
|
data/readme.md
CHANGED
|
@@ -31,6 +31,14 @@ Please see the [project documentation](https://socketry.github.io/async-service/
|
|
|
31
31
|
|
|
32
32
|
Please see the [project releases](https://socketry.github.io/async-service/releases/index) for all releases.
|
|
33
33
|
|
|
34
|
+
### v0.22.0
|
|
35
|
+
|
|
36
|
+
- Ensure process title is updated immediately after server starts in `Managed::Service`.
|
|
37
|
+
|
|
38
|
+
### v0.21.0
|
|
39
|
+
|
|
40
|
+
- Add missing bake files.
|
|
41
|
+
|
|
34
42
|
### v0.20.1
|
|
35
43
|
|
|
36
44
|
- Use `container.stopping?` in policy to prevent redundant stop calls during graceful shutdown.
|
|
@@ -74,15 +82,6 @@ Please see the [project releases](https://socketry.github.io/async-service/relea
|
|
|
74
82
|
|
|
75
83
|
- `Managed::Service` should run within `Async do ... end`.
|
|
76
84
|
|
|
77
|
-
### v0.15.0
|
|
78
|
-
|
|
79
|
-
- Rename `ContainerEnvironment` and `ContainerService` to `Managed::Environment` and `Managed::Service` respectively.
|
|
80
|
-
- Health check uses `Fiber.new{instance.ready!}.resume` to confirm fiber allocation is working.
|
|
81
|
-
|
|
82
|
-
### v0.14.4
|
|
83
|
-
|
|
84
|
-
- Use `String::Format` gem for formatting.
|
|
85
|
-
|
|
86
85
|
## Contributing
|
|
87
86
|
|
|
88
87
|
We welcome contributions to this project.
|
data/releases.md
CHANGED
|
@@ -1,5 +1,13 @@
|
|
|
1
1
|
# Releases
|
|
2
2
|
|
|
3
|
+
## v0.22.0
|
|
4
|
+
|
|
5
|
+
- Ensure process title is updated immediately after server starts in `Managed::Service`.
|
|
6
|
+
|
|
7
|
+
## v0.21.0
|
|
8
|
+
|
|
9
|
+
- Add missing bake files.
|
|
10
|
+
|
|
3
11
|
## v0.20.1
|
|
4
12
|
|
|
5
13
|
- Use `container.stopping?` in policy to prevent redundant stop calls during graceful shutdown.
|
data.tar.gz.sig
CHANGED
|
Binary file
|
metadata
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: async-service
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 0.
|
|
4
|
+
version: 0.22.0
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Samuel Williams
|
|
@@ -85,6 +85,8 @@ executables:
|
|
|
85
85
|
extensions: []
|
|
86
86
|
extra_rdoc_files: []
|
|
87
87
|
files:
|
|
88
|
+
- bake/async/service/configuration.rb
|
|
89
|
+
- bake/async/service/controller.rb
|
|
88
90
|
- bin/async-service
|
|
89
91
|
- context/best-practices.md
|
|
90
92
|
- context/deployment.md
|
|
@@ -124,14 +126,14 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
|
124
126
|
requirements:
|
|
125
127
|
- - ">="
|
|
126
128
|
- !ruby/object:Gem::Version
|
|
127
|
-
version: '3.
|
|
129
|
+
version: '3.3'
|
|
128
130
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
|
129
131
|
requirements:
|
|
130
132
|
- - ">="
|
|
131
133
|
- !ruby/object:Gem::Version
|
|
132
134
|
version: '0'
|
|
133
135
|
requirements: []
|
|
134
|
-
rubygems_version: 4.0.
|
|
136
|
+
rubygems_version: 4.0.6
|
|
135
137
|
specification_version: 4
|
|
136
138
|
summary: A service layer for Async.
|
|
137
139
|
test_files: []
|
metadata.gz.sig
CHANGED
|
Binary file
|