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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: a0a40d50b41d2ddb7691daa0b3911559150853ea1c060be2bd3dad1c75d6f549
4
- data.tar.gz: 5d24dc0724bf6cb013ed68072a6579368f50233b4e54ebffc1615fe300683fd0
3
+ metadata.gz: bd7c0c91471cbf80069a3c770f1a9489e1dac8a2b22db648a0942f31e35e2743
4
+ data.tar.gz: a1aa57c3746945251bde7ad98baec11d28bd477a9c39bfe33fcdf22ac9f42f71
5
5
  SHA512:
6
- metadata.gz: 68a1fb24248fba49149e69e209e452b5de54b250e03160164bc6447f16831d0081297dcfd4e849b85aef32aac3432520f9d7e4eb86fd0ddd08f1c3d225dcd942
7
- data.tar.gz: 3678501569e9b53da6540fe2d24fcbeffbe415acf779f8ca6c943ac67c627899d1a25ef488df8c65c348b54f20315c8faea44459f993ffaa771f590be63cdccc
6
+ metadata.gz: 400055e9c5d608f4eae1551304c25b96207e7b2c6b92cadeba6f476dac3c0de1a2ff2d24eb39da282d7ba52a0a6f90c400063b8a94fe883ca064ed3cbbcc1099
7
+ data.tar.gz: 0f416c8a882c91cc453111f0949498bf8e17d463b8dc623d06da07ca5e2435c966b2a6668c25170fe474afb9e684c368ef73522d6f29101cc1f319473624556a
checksums.yaml.gz.sig CHANGED
Binary file
data/bin/async-service CHANGED
@@ -1,6 +1,7 @@
1
1
  #!/usr/bin/env ruby
2
+ # frozen_string_literal: true
2
3
 
3
- require 'async/service'
4
+ require "async/service"
4
5
 
5
6
  configuration = Async::Service::Configuration.load
6
7
  Async::Service::Controller.run(configuration)
@@ -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 'loader'
7
- require_relative 'generic'
8
- require_relative 'controller'
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
- next if implementing and environment.implements?(implementing)
55
-
56
- yield Generic.wrap(environment)
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 'async/container/controller'
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 'bundler'
13
+ require "bundler"
14
14
  Bundler.require(:preload)
15
15
  rescue Bundler::GemfileNotFound, LoadError
16
16
  # Ignore.
@@ -67,6 +67,10 @@ module Async
67
67
  @facet.define_method(name){argument}
68
68
  end
69
69
  end
70
+
71
+ def respond_to_missing?(name, include_private = false)
72
+ true
73
+ end
70
74
  end
71
75
 
72
76
  def self.build(...)
@@ -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 service_class = evaluator.service_class || self
19
- return service_class.new(environment, evaluator)
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
 
@@ -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 'environment'
6
+ require_relative "environment"
7
7
 
8
8
  module Async
9
9
  module Service
10
- # The domain specific language for loading configuration files.
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 host with the specified name.
51
- # Adds `root` and `authority` keys.
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
- @configuration.add(self.environment(name: name, root: @root, &block))
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
@@ -5,6 +5,6 @@
5
5
 
6
6
  module Async
7
7
  module Service
8
- VERSION = "0.12.0"
8
+ VERSION = "0.13.0"
9
9
  end
10
10
  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 'service/configuration'
7
- require_relative 'service/controller'
8
- require_relative 'service/version'
6
+ require_relative "service/configuration"
7
+ require_relative "service/controller"
8
+ require_relative "service/version"
data/license.md CHANGED
@@ -1,6 +1,6 @@
1
1
  # MIT License
2
2
 
3
- Copyright, 2024, by Samuel Williams.
3
+ Copyright, 2024-2025, by Samuel Williams.
4
4
 
5
5
  Permission is hereby granted, free of charge, to any person obtaining a copy
6
6
  of this software and associated documentation files (the "Software"), to deal
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
- This project uses the [Developer Certificate of Origin](https://developercertificate.org/). All contributors to this project must agree to this document to have their contributions accepted.
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
- ### Contributor Covenant
21
+ ### Community Guidelines
22
22
 
23
- This project is governed by the [Contributor Covenant](https://www.contributor-covenant.org/). All contributors and participants agree to abide by its terms.
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.12.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: 2024-04-07 00:00:00.000000000 Z
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
- post_install_message:
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.0'
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.5.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