async-service 0.3.0 → 0.4.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: 2d808be31f6c38a51c562d5fbe62e9d0e00b2442f0da6396da3730c68952659b
4
- data.tar.gz: 26a493d2be8d2f30008d91a468cd0c5910c9fbd3dd8a2d06a06062c7e7f7b108
3
+ metadata.gz: 6d3363e029c4a990a1c3aebe2f246e55996dfdccc8c5a49b7d15c37222ee0334
4
+ data.tar.gz: cad8af3bf066578fafbcc38f9dd1a0f34800e79c6392811948a99a89dd0b1402
5
5
  SHA512:
6
- metadata.gz: 69d5030849df8fbbbda0b24174a305d34f21eb28f5d1af7c21c0f94143882bf6526331279d5b72d118bc8cad3e8a179882c34e36cc0fd84d2d4f61e5004ae50e
7
- data.tar.gz: a674262d6cee230b8897e3fd7fa58234e57be40b0ac2b1b2932013ea069d9b39d2e349722645d524a9cedabf2ee7d10e6d64d56bd16d7d875cf012eb68661c04
6
+ metadata.gz: 3ad2bbecc7ecf2598b7ebb103055eb15d773e163cf72b606e8d9c40762afb063ad03567cbc7ccc320934abf391b80e29b3cfeb418e3dc9ea32a6bcdd80d3702e
7
+ data.tar.gz: 67b80153901e82d6d46961beae562a47162aa236d230fd4ed9f4d7edebe19fd55c7b631928e99061d01e9f06265e270147ad2e84d301978d2cbac76540747888
checksums.yaml.gz.sig CHANGED
Binary file
data/bin/async-service CHANGED
@@ -2,26 +2,5 @@
2
2
 
3
3
  require 'async/service'
4
4
 
5
- configuration = Async::Service::Configuration.new
6
-
7
- ARGV.each do |path|
8
- configuration.load_file(path)
9
- end
10
-
11
- controller = Async::Service::Controller.new(configuration.services)
12
-
13
- begin
14
- require 'bundler'
15
- Bundler.require(:preload)
16
- rescue Bundler::GemfileNotFound, LoadError
17
- # Ignore.
18
- end
19
-
20
- if Process.respond_to?(:warmup)
21
- Process.warmup
22
- elsif GC.respond_to?(:compact)
23
- 3.times{GC.start}
24
- GC.compact
25
- end
26
-
27
- controller.run
5
+ configuration = Async::Service::Configuration.load
6
+ Async::Service::Controller.run(configuration)
@@ -12,6 +12,16 @@ module Async
12
12
  #
13
13
  # Environments are key-value maps with lazy value resolution. An environment can inherit from a parent environment, which can provide defaults
14
14
  class Configuration
15
+ def self.load(paths = ARGV)
16
+ configuration = self.new
17
+
18
+ paths.each do |path|
19
+ configuration.load_file(path)
20
+ end
21
+
22
+ return configuration
23
+ end
24
+
15
25
  # Initialize an empty configuration.
16
26
  def initialize
17
27
  @environments = []
@@ -8,6 +8,30 @@ require 'async/container/controller'
8
8
  module Async
9
9
  module Service
10
10
  class Controller < Async::Container::Controller
11
+ def self.warmup
12
+ begin
13
+ require 'bundler'
14
+ Bundler.require(:preload)
15
+ rescue Bundler::GemfileNotFound, LoadError
16
+ # Ignore.
17
+ end
18
+
19
+ if Process.respond_to?(:warmup)
20
+ Process.warmup
21
+ elsif GC.respond_to?(:compact)
22
+ 3.times{GC.start}
23
+ GC.compact
24
+ end
25
+ end
26
+
27
+ def self.run(configuration)
28
+ controller = Async::Service::Controller.new(configuration.services.to_a)
29
+
30
+ self.warmup
31
+
32
+ controller.run
33
+ end
34
+
11
35
  def initialize(services, **options)
12
36
  super(**options)
13
37
 
@@ -23,7 +47,7 @@ module Async
23
47
  super
24
48
  end
25
49
 
26
- # Setup all named services into the given container.
50
+ # Setup all services into the given container.
27
51
  #
28
52
  # @parameter container [Async::Container::Generic]
29
53
  def setup(container)
@@ -37,7 +37,7 @@ module Async
37
37
  elsif target.respond_to?(:included)
38
38
  target.included(@facet)
39
39
  else
40
- raise ::ArgumentError, "Cannot include #{target.inspect} into #{@facet}"
40
+ ::Kernel.raise ::ArgumentError, "Cannot include #{target.inspect} into #{@facet.inspect}!"
41
41
  end
42
42
  end
43
43
 
@@ -14,16 +14,17 @@ module Async
14
14
  # @parameter environment [Build::Environment] The environment to use to construct the service.
15
15
  def self.wrap(environment)
16
16
  evaluator = environment.evaluator
17
- service_class = evaluator.service_class || self
18
17
 
19
- return service_class.new(environment)
18
+ if service_class = evaluator.service_class || self
19
+ return service_class.new(environment, evaluator)
20
+ end
20
21
  end
21
22
 
22
23
  # Initialize the service from the given environment.
23
24
  # @parameter environment [Build::Environment]
24
- def initialize(environment)
25
+ def initialize(environment, evaluator = environment.evaluator)
25
26
  @environment = environment
26
- @evaluator = @environment.evaluator
27
+ @evaluator = evaluator
27
28
  end
28
29
 
29
30
  def to_h
@@ -5,6 +5,6 @@
5
5
 
6
6
  module Async
7
7
  module Service
8
- VERSION = "0.3.0"
8
+ VERSION = "0.4.0"
9
9
  end
10
10
  end
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.3.0
4
+ version: 0.4.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Samuel Williams
@@ -37,7 +37,7 @@ cert_chain:
37
37
  Q2K9NVun/S785AP05vKkXZEFYxqG6EW012U4oLcFl5MySFajYXRYbuUpH6AY+HP8
38
38
  voD0MPg1DssDLKwXyt1eKD/+Fq0bFWhwVM/1XiAXL7lyYUyOq24KHgQ2Csg=
39
39
  -----END CERTIFICATE-----
40
- date: 2024-03-10 00:00:00.000000000 Z
40
+ date: 2024-03-11 00:00:00.000000000 Z
41
41
  dependencies:
42
42
  - !ruby/object:Gem::Dependency
43
43
  name: async
metadata.gz.sig CHANGED
Binary file