nonnative 1.45.0 → 1.46.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
- data/CHANGELOG.md +7 -0
- data/Gemfile.lock +1 -1
- data/README.md +15 -5
- data/lib/nonnative.rb +0 -4
- data/lib/nonnative/configuration.rb +78 -81
- data/lib/nonnative/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 5ab3f3907cd50fe1984cc57c28da9a17612beba23d73e8e82111ab133569a082
|
4
|
+
data.tar.gz: 71601b678ec6a2dbf53a1a2347955c691619dcf7310224d974d0b84bdc4de922
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 0bcee6e1dfcba57e0a6be43cff1be649f9fcff7c1ec94a26cca48e47b1ae0d734a279ff61464acdca5e531ba4abfb79479a9f473bd893f63d97efa575b7387e4
|
7
|
+
data.tar.gz: 91d0a695d1d2efc013af95e4a10db2637c8d47dfa21ab49a0765098f7f69c34520e514598aadca2652d69610b7baeea76822388c6030f33b3f0c78c33ec039ea
|
data/CHANGELOG.md
CHANGED
@@ -2,6 +2,13 @@
|
|
2
2
|
|
3
3
|
All notable changes to this project will be documented in this file. See [standard-version](https://github.com/conventional-changelog/standard-version) for commit guidelines.
|
4
4
|
|
5
|
+
## [1.46.0](https://github.com/alexfalkowski/nonnative/compare/v1.45.0...v1.46.0) (2021-05-10)
|
6
|
+
|
7
|
+
|
8
|
+
### Features
|
9
|
+
|
10
|
+
* add loading config through configure ([#87](https://github.com/alexfalkowski/nonnative/issues/87)) ([a95e8b6](https://github.com/alexfalkowski/nonnative/commit/a95e8b6817380afd732d0aefb170726f905548cb))
|
11
|
+
|
5
12
|
## [1.45.0](https://github.com/alexfalkowski/nonnative/compare/v1.44.1...v1.45.0) (2021-05-10)
|
6
13
|
|
7
14
|
|
data/Gemfile.lock
CHANGED
data/README.md
CHANGED
@@ -108,7 +108,9 @@ Then load the file with
|
|
108
108
|
```ruby
|
109
109
|
require 'nonnative'
|
110
110
|
|
111
|
-
Nonnative.
|
111
|
+
Nonnative.configure do |config|
|
112
|
+
config.load_file('configuration.yml')
|
113
|
+
end
|
112
114
|
```
|
113
115
|
|
114
116
|
### Servers
|
@@ -189,7 +191,9 @@ Then load the file with:
|
|
189
191
|
```ruby
|
190
192
|
require 'nonnative'
|
191
193
|
|
192
|
-
Nonnative.
|
194
|
+
Nonnative.configure do |config|
|
195
|
+
config.load_file('configuration.yml')
|
196
|
+
end
|
193
197
|
```
|
194
198
|
|
195
199
|
#### HTTP
|
@@ -255,7 +259,9 @@ Then load the file with:
|
|
255
259
|
```ruby
|
256
260
|
require 'nonnative'
|
257
261
|
|
258
|
-
Nonnative.
|
262
|
+
Nonnative.configure do |config|
|
263
|
+
config.load_file('configuration.yml')
|
264
|
+
end
|
259
265
|
```
|
260
266
|
|
261
267
|
#### gRPC
|
@@ -317,7 +323,9 @@ Then load the file with:
|
|
317
323
|
```ruby
|
318
324
|
require 'nonnative'
|
319
325
|
|
320
|
-
Nonnative.
|
326
|
+
Nonnative.configure do |config|
|
327
|
+
config.load_file('configuration.yml')
|
328
|
+
end
|
321
329
|
```
|
322
330
|
|
323
331
|
### Services
|
@@ -363,7 +371,9 @@ Then load the file with
|
|
363
371
|
```ruby
|
364
372
|
require 'nonnative'
|
365
373
|
|
366
|
-
Nonnative.
|
374
|
+
Nonnative.configure do |config|
|
375
|
+
config.load_file('configuration.yml')
|
376
|
+
end
|
367
377
|
```
|
368
378
|
|
369
379
|
#### Proxies
|
data/lib/nonnative.rb
CHANGED
@@ -60,10 +60,6 @@ module Nonnative
|
|
60
60
|
Nonnative::GoCommand.new(exec, output).executable(cmd, params)
|
61
61
|
end
|
62
62
|
|
63
|
-
def load_configuration(path)
|
64
|
-
@configuration ||= Nonnative::Configuration.load_file(path) # rubocop:disable Naming/MemoizedInstanceVariableName
|
65
|
-
end
|
66
|
-
|
67
63
|
def configuration
|
68
64
|
@configuration ||= Nonnative::Configuration.new
|
69
65
|
end
|
@@ -2,87 +2,6 @@
|
|
2
2
|
|
3
3
|
module Nonnative
|
4
4
|
class Configuration
|
5
|
-
class << self
|
6
|
-
def load_file(path)
|
7
|
-
file = YAML.load_file(path)
|
8
|
-
|
9
|
-
new.tap do |c|
|
10
|
-
c.strategy = file['strategy']
|
11
|
-
|
12
|
-
processes(file, c)
|
13
|
-
servers(file, c)
|
14
|
-
services(file, c)
|
15
|
-
end
|
16
|
-
end
|
17
|
-
|
18
|
-
private
|
19
|
-
|
20
|
-
def processes(file, config)
|
21
|
-
processes = file['processes'] || []
|
22
|
-
processes.each do |fd|
|
23
|
-
config.process do |d|
|
24
|
-
d.name = fd['name']
|
25
|
-
d.command = command(fd)
|
26
|
-
d.timeout = fd['timeout']
|
27
|
-
d.port = fd['port']
|
28
|
-
d.log = fd['log']
|
29
|
-
d.signal = fd['signal']
|
30
|
-
|
31
|
-
proxy d, fd['proxy']
|
32
|
-
end
|
33
|
-
end
|
34
|
-
end
|
35
|
-
|
36
|
-
def command(process)
|
37
|
-
go = process['go']
|
38
|
-
if go
|
39
|
-
Nonnative.go_executable(go['output'], go['executable'], go['command'], *go['parameters'])
|
40
|
-
else
|
41
|
-
process['command']
|
42
|
-
end
|
43
|
-
end
|
44
|
-
|
45
|
-
def servers(file, config)
|
46
|
-
servers = file['servers'] || []
|
47
|
-
servers.each do |fd|
|
48
|
-
config.server do |s|
|
49
|
-
s.name = fd['name']
|
50
|
-
s.klass = Object.const_get(fd['class'])
|
51
|
-
s.timeout = fd['timeout']
|
52
|
-
s.port = fd['port']
|
53
|
-
s.log = fd['log']
|
54
|
-
|
55
|
-
proxy s, fd['proxy']
|
56
|
-
end
|
57
|
-
end
|
58
|
-
end
|
59
|
-
|
60
|
-
def services(file, config)
|
61
|
-
services = file['services'] || []
|
62
|
-
services.each do |fd|
|
63
|
-
config.service do |s|
|
64
|
-
s.name = fd['name']
|
65
|
-
s.timeout = fd['timeout']
|
66
|
-
s.port = fd['port']
|
67
|
-
s.log = fd['log']
|
68
|
-
|
69
|
-
proxy s, fd['proxy']
|
70
|
-
end
|
71
|
-
end
|
72
|
-
end
|
73
|
-
|
74
|
-
def proxy(server, proxy)
|
75
|
-
return unless proxy
|
76
|
-
|
77
|
-
server.proxy = {
|
78
|
-
type: proxy['type'],
|
79
|
-
port: proxy['port'],
|
80
|
-
log: proxy['log'],
|
81
|
-
options: proxy['options']
|
82
|
-
}
|
83
|
-
end
|
84
|
-
end
|
85
|
-
|
86
5
|
def initialize
|
87
6
|
@strategy = Strategy.new
|
88
7
|
@processes = []
|
@@ -93,6 +12,16 @@ module Nonnative
|
|
93
12
|
attr_accessor :processes, :servers, :services
|
94
13
|
attr_reader :strategy
|
95
14
|
|
15
|
+
def load_file(path)
|
16
|
+
file = YAML.load_file(path)
|
17
|
+
|
18
|
+
self.strategy = file['strategy']
|
19
|
+
|
20
|
+
add_processes(file)
|
21
|
+
add_servers(file)
|
22
|
+
add_services(file)
|
23
|
+
end
|
24
|
+
|
96
25
|
def strategy=(value)
|
97
26
|
@strategy = Strategy.new(value)
|
98
27
|
end
|
@@ -117,5 +46,73 @@ module Nonnative
|
|
117
46
|
|
118
47
|
services << service
|
119
48
|
end
|
49
|
+
|
50
|
+
private
|
51
|
+
|
52
|
+
def add_processes(file)
|
53
|
+
processes = file['processes'] || []
|
54
|
+
processes.each do |fd|
|
55
|
+
process do |d|
|
56
|
+
d.name = fd['name']
|
57
|
+
d.command = command(fd)
|
58
|
+
d.timeout = fd['timeout']
|
59
|
+
d.port = fd['port']
|
60
|
+
d.log = fd['log']
|
61
|
+
d.signal = fd['signal']
|
62
|
+
|
63
|
+
proxy d, fd['proxy']
|
64
|
+
end
|
65
|
+
end
|
66
|
+
end
|
67
|
+
|
68
|
+
def command(process)
|
69
|
+
go = process['go']
|
70
|
+
if go
|
71
|
+
params = go['parameters'] || []
|
72
|
+
Nonnative.go_executable(go['output'], go['executable'], go['command'], *params)
|
73
|
+
else
|
74
|
+
process['command']
|
75
|
+
end
|
76
|
+
end
|
77
|
+
|
78
|
+
def add_servers(file)
|
79
|
+
servers = file['servers'] || []
|
80
|
+
servers.each do |fd|
|
81
|
+
server do |s|
|
82
|
+
s.name = fd['name']
|
83
|
+
s.klass = Object.const_get(fd['class'])
|
84
|
+
s.timeout = fd['timeout']
|
85
|
+
s.port = fd['port']
|
86
|
+
s.log = fd['log']
|
87
|
+
|
88
|
+
proxy s, fd['proxy']
|
89
|
+
end
|
90
|
+
end
|
91
|
+
end
|
92
|
+
|
93
|
+
def add_services(file)
|
94
|
+
services = file['services'] || []
|
95
|
+
services.each do |fd|
|
96
|
+
service do |s|
|
97
|
+
s.name = fd['name']
|
98
|
+
s.timeout = fd['timeout']
|
99
|
+
s.port = fd['port']
|
100
|
+
s.log = fd['log']
|
101
|
+
|
102
|
+
proxy s, fd['proxy']
|
103
|
+
end
|
104
|
+
end
|
105
|
+
end
|
106
|
+
|
107
|
+
def proxy(runner, proxy)
|
108
|
+
return unless proxy
|
109
|
+
|
110
|
+
runner.proxy = {
|
111
|
+
type: proxy['type'],
|
112
|
+
port: proxy['port'],
|
113
|
+
log: proxy['log'],
|
114
|
+
options: proxy['options']
|
115
|
+
}
|
116
|
+
end
|
120
117
|
end
|
121
118
|
end
|
data/lib/nonnative/version.rb
CHANGED