async-service 0.3.1 → 0.4.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 383a3a329442a291c3ec373e55626e1a10ab01e237aa545787f7282c8bace859
4
- data.tar.gz: 0b3436a1ccf535c15fcd90b59b77dbc3e2638170496a2c7d8298d76134edb3a3
3
+ metadata.gz: 6d3363e029c4a990a1c3aebe2f246e55996dfdccc8c5a49b7d15c37222ee0334
4
+ data.tar.gz: cad8af3bf066578fafbcc38f9dd1a0f34800e79c6392811948a99a89dd0b1402
5
5
  SHA512:
6
- metadata.gz: f419c921dec91bd81a3b0a51e08471017fd3d8a31fb3fcfdf0abb0c53eb044b131f190be5a93f33b37d0a2eee3c4935ce55e3ce67bc3217db01b818abaa5fe24
7
- data.tar.gz: 84decffdf10d7e0dc269f812e83dc5a780615a6d90ff51237743f1ffa48fd96e7b436516ecc4b1c14ea7ec8b0b379a2e8c613ef3affa0da3bf1b3f4f3103754c
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)
@@ -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.1"
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.1
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