async-service 0.12.0 → 0.13.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/bin/async-service +2 -1
- data/lib/async/service/configuration.rb +18 -7
- data/lib/async/service/controller.rb +3 -3
- data/lib/async/service/environment.rb +4 -0
- data/lib/async/service/generic.rb +6 -3
- data/lib/async/service/loader.rb +10 -7
- data/lib/async/service/version.rb +1 -1
- data/lib/async/service.rb +4 -4
- data/license.md +1 -1
- data/readme.md +3 -3
- data.tar.gz.sig +0 -0
- metadata +5 -9
- 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: bd7c0c91471cbf80069a3c770f1a9489e1dac8a2b22db648a0942f31e35e2743
|
4
|
+
data.tar.gz: a1aa57c3746945251bde7ad98baec11d28bd477a9c39bfe33fcdf22ac9f42f71
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 400055e9c5d608f4eae1551304c25b96207e7b2c6b92cadeba6f476dac3c0de1a2ff2d24eb39da282d7ba52a0a6f90c400063b8a94fe883ca064ed3cbbcc1099
|
7
|
+
data.tar.gz: 0f416c8a882c91cc453111f0949498bf8e17d463b8dc623d06da07ca5e2435c966b2a6668c25170fe474afb9e684c368ef73522d6f29101cc1f319473624556a
|
checksums.yaml.gz.sig
CHANGED
Binary file
|
data/bin/async-service
CHANGED
@@ -1,11 +1,11 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
3
|
# Released under the MIT License.
|
4
|
-
# Copyright, 2024, by Samuel Williams.
|
4
|
+
# Copyright, 2024-2025, by Samuel Williams.
|
5
5
|
|
6
|
-
require_relative
|
7
|
-
require_relative
|
8
|
-
require_relative
|
6
|
+
require_relative "loader"
|
7
|
+
require_relative "generic"
|
8
|
+
require_relative "controller"
|
9
9
|
|
10
10
|
module Async
|
11
11
|
module Service
|
@@ -47,16 +47,27 @@ module Async
|
|
47
47
|
@environments.empty?
|
48
48
|
end
|
49
49
|
|
50
|
+
# Enumerate all services in the configuration.
|
51
|
+
#
|
52
|
+
# A service is an environment that has a `service_class` key.
|
53
|
+
#
|
54
|
+
# @parameter implementing [Module] If specified, only services implementing this module will be returned/yielded.
|
55
|
+
# @yields {|service| ...} Each service in the configuration.
|
50
56
|
def services(implementing: nil)
|
51
57
|
return to_enum(:services, implementing: implementing) unless block_given?
|
52
58
|
|
53
59
|
@environments.each do |environment|
|
54
|
-
|
55
|
-
|
56
|
-
|
60
|
+
if implementing.nil? or environment.implements?(implementing)
|
61
|
+
if service = Generic.wrap(environment)
|
62
|
+
yield service
|
63
|
+
end
|
64
|
+
end
|
57
65
|
end
|
58
66
|
end
|
59
67
|
|
68
|
+
# Create a controller for the configured services.
|
69
|
+
#
|
70
|
+
# @returns [Controller] A controller that can be used to start/stop services.
|
60
71
|
def controller(**options)
|
61
72
|
Controller.new(self.services(**options).to_a)
|
62
73
|
end
|
@@ -1,16 +1,16 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
3
|
# Released under the MIT License.
|
4
|
-
# Copyright, 2024, by Samuel Williams.
|
4
|
+
# Copyright, 2024-2025, by Samuel Williams.
|
5
5
|
|
6
|
-
require
|
6
|
+
require "async/container/controller"
|
7
7
|
|
8
8
|
module Async
|
9
9
|
module Service
|
10
10
|
class Controller < Async::Container::Controller
|
11
11
|
def self.warmup
|
12
12
|
begin
|
13
|
-
require
|
13
|
+
require "bundler"
|
14
14
|
Bundler.require(:preload)
|
15
15
|
rescue Bundler::GemfileNotFound, LoadError
|
16
16
|
# Ignore.
|
@@ -1,7 +1,7 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
3
|
# Released under the MIT License.
|
4
|
-
# Copyright, 2024, by Samuel Williams.
|
4
|
+
# Copyright, 2024-2025, by Samuel Williams.
|
5
5
|
|
6
6
|
module Async
|
7
7
|
module Service
|
@@ -12,11 +12,14 @@ module Async
|
|
12
12
|
class Generic
|
13
13
|
# Convert the given environment into a service if possible.
|
14
14
|
# @parameter environment [Build::Environment] The environment to use to construct the service.
|
15
|
+
# @returns [Generic | Nil] The constructed service if the environment specifies a service class.
|
15
16
|
def self.wrap(environment)
|
16
17
|
evaluator = environment.evaluator
|
17
18
|
|
18
|
-
if
|
19
|
-
|
19
|
+
if evaluator.key?(:service_class)
|
20
|
+
if service_class = evaluator.service_class
|
21
|
+
return service_class.new(environment, evaluator)
|
22
|
+
end
|
20
23
|
end
|
21
24
|
end
|
22
25
|
|
data/lib/async/service/loader.rb
CHANGED
@@ -1,13 +1,13 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
3
|
# Released under the MIT License.
|
4
|
-
# Copyright, 2024, by Samuel Williams.
|
4
|
+
# Copyright, 2024-2025, by Samuel Williams.
|
5
5
|
|
6
|
-
require_relative
|
6
|
+
require_relative "environment"
|
7
7
|
|
8
8
|
module Async
|
9
9
|
module Service
|
10
|
-
|
10
|
+
# The domain specific language for loading configuration files.
|
11
11
|
class Loader
|
12
12
|
# Initialize the loader, attached to a specific configuration instance.
|
13
13
|
# Any environments generated by the loader will be added to the configuration.
|
@@ -47,11 +47,14 @@ module Async
|
|
47
47
|
Environment.build(**initial, &block)
|
48
48
|
end
|
49
49
|
|
50
|
-
# Define a
|
51
|
-
# Adds `root` and `
|
50
|
+
# Define a service with the specified name.
|
51
|
+
# Adds `root` and `name` keys.
|
52
52
|
# @parameter name [String] The name of the environment, usually a hostname.
|
53
|
-
def service(name, &block)
|
54
|
-
|
53
|
+
def service(name = nil, **options, &block)
|
54
|
+
options[:name] = name
|
55
|
+
options[:root] ||= @root
|
56
|
+
|
57
|
+
@configuration.add(self.environment(**options, &block))
|
55
58
|
end
|
56
59
|
end
|
57
60
|
end
|
data/lib/async/service.rb
CHANGED
@@ -1,8 +1,8 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
3
|
# Released under the MIT License.
|
4
|
-
# Copyright, 2024, by Samuel Williams.
|
4
|
+
# Copyright, 2024-2025, by Samuel Williams.
|
5
5
|
|
6
|
-
require_relative
|
7
|
-
require_relative
|
8
|
-
require_relative
|
6
|
+
require_relative "service/configuration"
|
7
|
+
require_relative "service/controller"
|
8
|
+
require_relative "service/version"
|
data/license.md
CHANGED
data/readme.md
CHANGED
@@ -16,8 +16,8 @@ We welcome contributions to this project.
|
|
16
16
|
|
17
17
|
### Developer Certificate of Origin
|
18
18
|
|
19
|
-
|
19
|
+
In order to protect users of this project, we require all contributors to comply with the [Developer Certificate of Origin](https://developercertificate.org/). This ensures that all contributions are properly licensed and attributed.
|
20
20
|
|
21
|
-
###
|
21
|
+
### Community Guidelines
|
22
22
|
|
23
|
-
This project is
|
23
|
+
This project is best served by a collaborative and respectful environment. Treat each other professionally, respect differing viewpoints, and engage constructively. Harassment, discrimination, or harmful behavior is not tolerated. Communicate clearly, listen actively, and support one another. If any issues arise, please inform the project maintainers.
|
data.tar.gz.sig
CHANGED
Binary file
|
metadata
CHANGED
@@ -1,11 +1,10 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: async-service
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.13.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Samuel Williams
|
8
|
-
autorequire:
|
9
8
|
bindir: bin
|
10
9
|
cert_chain:
|
11
10
|
- |
|
@@ -37,7 +36,7 @@ cert_chain:
|
|
37
36
|
Q2K9NVun/S785AP05vKkXZEFYxqG6EW012U4oLcFl5MySFajYXRYbuUpH6AY+HP8
|
38
37
|
voD0MPg1DssDLKwXyt1eKD/+Fq0bFWhwVM/1XiAXL7lyYUyOq24KHgQ2Csg=
|
39
38
|
-----END CERTIFICATE-----
|
40
|
-
date:
|
39
|
+
date: 2025-03-08 00:00:00.000000000 Z
|
41
40
|
dependencies:
|
42
41
|
- !ruby/object:Gem::Dependency
|
43
42
|
name: async
|
@@ -67,8 +66,6 @@ dependencies:
|
|
67
66
|
- - "~>"
|
68
67
|
- !ruby/object:Gem::Version
|
69
68
|
version: '0.16'
|
70
|
-
description:
|
71
|
-
email:
|
72
69
|
executables:
|
73
70
|
- async-service
|
74
71
|
extensions: []
|
@@ -89,7 +86,7 @@ licenses:
|
|
89
86
|
- MIT
|
90
87
|
metadata:
|
91
88
|
documentation_uri: https://socketry.github.io/async-service/
|
92
|
-
|
89
|
+
source_code_uri: https://github.com/socketry/async-service.git
|
93
90
|
rdoc_options: []
|
94
91
|
require_paths:
|
95
92
|
- lib
|
@@ -97,15 +94,14 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
97
94
|
requirements:
|
98
95
|
- - ">="
|
99
96
|
- !ruby/object:Gem::Version
|
100
|
-
version: '3.
|
97
|
+
version: '3.1'
|
101
98
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
102
99
|
requirements:
|
103
100
|
- - ">="
|
104
101
|
- !ruby/object:Gem::Version
|
105
102
|
version: '0'
|
106
103
|
requirements: []
|
107
|
-
rubygems_version: 3.
|
108
|
-
signing_key:
|
104
|
+
rubygems_version: 3.6.2
|
109
105
|
specification_version: 4
|
110
106
|
summary: A service layer for Async.
|
111
107
|
test_files: []
|
metadata.gz.sig
CHANGED
Binary file
|