ntl-process_host 0.0.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/lib/process_host.rb +8 -0
- data/lib/process_host/component.rb +24 -0
- data/lib/process_host/component/name_list.rb +21 -0
- data/lib/process_host/controls.rb +4 -0
- data/lib/process_host/controls/actor.rb +5 -0
- data/lib/process_host/controls/component.rb +19 -0
- data/lib/process_host/environment.rb +21 -0
- data/lib/process_host/host.rb +43 -0
- data/lib/process_host/process_host.rb +9 -0
- metadata +66 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 47fe7060d30b7ef20cd3dc1d7134e378423920c9
|
4
|
+
data.tar.gz: 685dd2f57aedcb4ab7be0caf3419e97fa6b1a6b7
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 3713ba47cb0dc089f37642a77ffb0de319ee6b2e87f2ff46c21e4eb164f631f06725da19e138c6c3ce48d82251206accf8263aeacb578b8126e3a11d25886f07
|
7
|
+
data.tar.gz: 49615043dfa4a38c83c683d017698e8479cbf146aebc04bb21affccc7dbb8490d99267b222b9f6c66dd6039c92f748b562cf4154a761e86e64af4982a088bb8f
|
data/lib/process_host.rb
ADDED
@@ -0,0 +1,24 @@
|
|
1
|
+
module ProcessHost
|
2
|
+
module Component
|
3
|
+
def self.included cls
|
4
|
+
cls.class_exec do
|
5
|
+
extend Start
|
6
|
+
end
|
7
|
+
end
|
8
|
+
|
9
|
+
attr_writer :supervisor
|
10
|
+
|
11
|
+
def supervisor
|
12
|
+
@supervisor ||= Actor::Supervisor.new
|
13
|
+
end
|
14
|
+
|
15
|
+
module Start
|
16
|
+
def start supervisor=nil
|
17
|
+
instance = new
|
18
|
+
instance.supervisor = supervisor
|
19
|
+
instance.start
|
20
|
+
instance
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|
24
|
+
end
|
@@ -0,0 +1,21 @@
|
|
1
|
+
module ProcessHost
|
2
|
+
module Component
|
3
|
+
module NameList
|
4
|
+
def self.get env
|
5
|
+
component_names = env['PROCESS_HOST_COMPONENTS']
|
6
|
+
|
7
|
+
if component_names.nil?
|
8
|
+
Any
|
9
|
+
else
|
10
|
+
component_names.split ','
|
11
|
+
end
|
12
|
+
end
|
13
|
+
|
14
|
+
module Any
|
15
|
+
def self.include? component_name
|
16
|
+
true
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
@@ -0,0 +1,19 @@
|
|
1
|
+
module ProcessHost
|
2
|
+
module Controls
|
3
|
+
module Component
|
4
|
+
class Example
|
5
|
+
include ProcessHost::Component
|
6
|
+
|
7
|
+
def start
|
8
|
+
address, thread = Actor::Example.start include: %i(thread)
|
9
|
+
|
10
|
+
supervisor.add address, thread
|
11
|
+
end
|
12
|
+
|
13
|
+
A = Class.new Example
|
14
|
+
B = Class.new Example
|
15
|
+
C = Class.new Example
|
16
|
+
end
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
@@ -0,0 +1,21 @@
|
|
1
|
+
module ProcessHost
|
2
|
+
module Environment
|
3
|
+
module ComponentNameList
|
4
|
+
def self.get env
|
5
|
+
component_names = env['PROCESS_HOST_COMPONENTS']
|
6
|
+
|
7
|
+
if component_names.nil?
|
8
|
+
Any
|
9
|
+
else
|
10
|
+
component_names.split ','
|
11
|
+
end
|
12
|
+
end
|
13
|
+
|
14
|
+
module Any
|
15
|
+
def self.include? component_name
|
16
|
+
true
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
@@ -0,0 +1,43 @@
|
|
1
|
+
module ProcessHost
|
2
|
+
class Host
|
3
|
+
attr_reader :component_names
|
4
|
+
attr_reader :supervisor
|
5
|
+
|
6
|
+
def initialize supervisor, component_names
|
7
|
+
@component_names = component_names
|
8
|
+
@supervisor = supervisor
|
9
|
+
end
|
10
|
+
|
11
|
+
def self.build env=nil, supervisor: nil, &block
|
12
|
+
env ||= ENV
|
13
|
+
|
14
|
+
supervisor ||= Actor::Supervisor.new
|
15
|
+
|
16
|
+
component_names = Component::NameList.get env
|
17
|
+
|
18
|
+
instance = new supervisor, component_names
|
19
|
+
instance.instance_exec supervisor, &block
|
20
|
+
instance
|
21
|
+
end
|
22
|
+
|
23
|
+
def component component_class
|
24
|
+
return unless component_names.include? component_class.name
|
25
|
+
|
26
|
+
component = component_class.start supervisor
|
27
|
+
components << component
|
28
|
+
component
|
29
|
+
end
|
30
|
+
|
31
|
+
def components
|
32
|
+
@components ||= Set.new
|
33
|
+
end
|
34
|
+
|
35
|
+
module Assertions
|
36
|
+
def component? component_class
|
37
|
+
components.any? do |component|
|
38
|
+
component.instance_of? component_class
|
39
|
+
end
|
40
|
+
end
|
41
|
+
end
|
42
|
+
end
|
43
|
+
end
|
metadata
ADDED
@@ -0,0 +1,66 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: ntl-process_host
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.0
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Nathan Ladd
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2016-08-31 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: ntl-actor
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - ">="
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '0'
|
20
|
+
type: :runtime
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - ">="
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '0'
|
27
|
+
description: Ruby library for hosting components composed of independent actors
|
28
|
+
email: nathanladd+github@gmail.com
|
29
|
+
executables: []
|
30
|
+
extensions: []
|
31
|
+
extra_rdoc_files: []
|
32
|
+
files:
|
33
|
+
- lib/process_host.rb
|
34
|
+
- lib/process_host/component.rb
|
35
|
+
- lib/process_host/component/name_list.rb
|
36
|
+
- lib/process_host/controls.rb
|
37
|
+
- lib/process_host/controls/actor.rb
|
38
|
+
- lib/process_host/controls/component.rb
|
39
|
+
- lib/process_host/environment.rb
|
40
|
+
- lib/process_host/host.rb
|
41
|
+
- lib/process_host/process_host.rb
|
42
|
+
homepage: https://github.com/ntl/process-host
|
43
|
+
licenses:
|
44
|
+
- MIT
|
45
|
+
metadata: {}
|
46
|
+
post_install_message:
|
47
|
+
rdoc_options: []
|
48
|
+
require_paths:
|
49
|
+
- lib
|
50
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - ">="
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '0'
|
55
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
56
|
+
requirements:
|
57
|
+
- - ">="
|
58
|
+
- !ruby/object:Gem::Version
|
59
|
+
version: '0'
|
60
|
+
requirements: []
|
61
|
+
rubyforge_project:
|
62
|
+
rubygems_version: 2.6.6
|
63
|
+
signing_key:
|
64
|
+
specification_version: 4
|
65
|
+
summary: Ruby library for hosting components
|
66
|
+
test_files: []
|