kumonos 0.9.3 → 0.10.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
  SHA1:
3
- metadata.gz: 7f54de23236dbfefde8bd14f5be106c2f4002842
4
- data.tar.gz: 0a27bc7bff3ef92b649b409eddaf143b64400a14
3
+ metadata.gz: 915ab24e5e48fa1761ae23b2c8a2ba09a666da2d
4
+ data.tar.gz: 288b08db40ab2aea699a74307b73785dca54c7ae
5
5
  SHA512:
6
- metadata.gz: 9969836a2938ff2cd6422b0f840bbc8f78c88a50ebaaa4a6f8dd22cc90c345f172068a32ded68ae02b5f4dc59345b9b770bf03598524a3a6060b23edc3e87e18
7
- data.tar.gz: 71d5a2db977eeba1119243f4e4581f91eef5262d6004c317fe6803d5aef168dbb2e8f8c8c4082fa0a2119c90119bdb60d908305f4a40722c9745b4488e8918bd
6
+ metadata.gz: 0d72019bf70fb44ddf776d3f372b0b4d465e668f2bcf78c070f59d48a40c1fc4e9767b1f4c8a5d85d7dfb99c13402e978f551719513029b46c4ea3791aa0d4b5
7
+ data.tar.gz: ca3f1c8d749de34b5ee3e6df3e930dfeeaee1728de0d4b48dd4488620eb5e73c652059dc15a1fb55c7a26628f214252c6437c82c6fdad34c9509f423503aea11
data/.rubocop.yml CHANGED
@@ -6,6 +6,8 @@ Metrics/BlockLength:
6
6
  Enabled: false
7
7
  Metrics/ClassLength:
8
8
  Enabled: false
9
+ Metrics/ModuleLength:
10
+ Enabled: false
9
11
  Metrics/MethodLength:
10
12
  Enabled: false
11
13
  Metrics/LineLength:
@@ -0,0 +1,17 @@
1
+ version: 1
2
+ listener:
3
+ address: tcp://0.0.0.0:9211
4
+ access_log_path: /dev/stdout
5
+ admin:
6
+ address: tcp://0.0.0.0:9901
7
+ access_log_path: /dev/stdout
8
+ discovery_service:
9
+ lb: nginx:80
10
+ tls: false
11
+ refresh_delay_ms: 30000
12
+ connect_timeout_ms: 1000
13
+ statsd:
14
+ address: relay:2000
15
+ tls: false
16
+ type: strict_dns
17
+ connect_timeout_ms: 1000
data/exe/kumonos CHANGED
@@ -12,26 +12,13 @@ class KumonosCli < Thor
12
12
  end
13
13
 
14
14
  desc 'envoy ENVOY_DEFINITION', 'Generate envoy configuration'
15
+ method_option :output, aliases: '-o', desc: 'Output path', required: true, type: :string
15
16
  def envoy(path)
16
17
  validate_path!(path)
17
- definition = JSON.parse(File.read(path))
18
+ definition = YAML.load_file(path)
18
19
  validate_envoy_definition!(definition, path)
19
- puts JSON.dump(Kumonos::Envoy.generate(definition))
20
- end
21
20
 
22
- desc 'init_envoy', 'Generate envoy definition'
23
- def init_envoy
24
- path = 'envoy.json'
25
- definition = JSON.parse(File.read(File.expand_path('../example/envoy.json', __dir__)))
26
- definition.delete('statsd')
27
- cluster = definition.fetch('ds').fetch('cluster')
28
- host = 'your-load-balancer-to-discovery-service'
29
- cluster['name'] = host
30
- cluster['hosts'] = [{ url: "tcp://#{host}:443" }]
31
- cluster['tls'] = true
32
- definition.fetch('ds')['cluster'] = cluster
33
- File.write(path, JSON.pretty_generate(definition) + "\n")
34
- puts path
21
+ File.write(options.fetch(:output), JSON.dump(Kumonos::Envoy.generate(definition)))
35
22
  end
36
23
 
37
24
  desc 'clusters SERVIVE_DEFINITION', 'Generate clusters configuration'
data/lib/kumonos/envoy.rb CHANGED
@@ -7,29 +7,42 @@ module Kumonos
7
7
  end
8
8
  end
9
9
 
10
- EnvoyConfig = Struct.new(:version, :ds, :statsd, :listener, :admin) do
10
+ EnvoyConfig = Struct.new(:version, :discovery_service, :statsd, :listener, :admin) do
11
11
  class << self
12
12
  def build(h)
13
- ds = DiscoverService.build(h.fetch('ds'))
13
+ discovery_service = DiscoverService.build(h.fetch('discovery_service'))
14
14
  new(
15
15
  h.fetch('version'),
16
- ds,
17
- h['statsd'] ? Cluster.build(h['statsd']) : nil,
18
- Listener.build(h.fetch('listener'), ds),
16
+ discovery_service,
17
+ h['statsd'] ? build_statsd_cluster(h['statsd']) : nil,
18
+ Listener.build(h.fetch('listener'), discovery_service),
19
19
  Admin.build(h.fetch('admin'))
20
20
  )
21
21
  end
22
+
23
+ private
24
+
25
+ def build_statsd_cluster(h)
26
+ Cluster.new(
27
+ 'statsd',
28
+ h.fetch('type'),
29
+ h.fetch('tls'),
30
+ h.fetch('connect_timeout_ms'),
31
+ 'round_robin',
32
+ [{ 'url' => "tcp://#{h.fetch('address')}" }]
33
+ )
34
+ end
22
35
  end
23
36
 
24
37
  def to_h
25
38
  h = super
26
39
  h.delete(:version)
27
- h.delete(:ds)
40
+ h.delete(:discovery_service)
28
41
  h.delete(:statsd)
29
42
  h.delete(:listener)
30
43
  h[:admin] = admin.to_h
31
44
  h[:listeners] = [listener.to_h]
32
- h[:cluster_manager] = { cds: ds.to_h, clusters: [] }
45
+ h[:cluster_manager] = { cds: discovery_service.to_h, clusters: [] }
33
46
 
34
47
  if statsd
35
48
  h[:statsd_tcp_cluster_name] = statsd.name
@@ -40,16 +53,16 @@ module Kumonos
40
53
  end
41
54
  end
42
55
 
43
- Listener = Struct.new(:address, :access_log_path, :ds) do
56
+ Listener = Struct.new(:address, :access_log_path, :discovery_service) do
44
57
  class << self
45
- def build(h, ds)
46
- new(h.fetch('address'), h.fetch('access_log_path'), ds)
58
+ def build(h, discovery_service)
59
+ new(h.fetch('address'), h.fetch('access_log_path'), discovery_service)
47
60
  end
48
61
  end
49
62
 
50
63
  def to_h
51
64
  h = super
52
- h.delete(:ds)
65
+ h.delete(:discovery_service)
53
66
  h.delete(:access_log_path)
54
67
  h[:filters] = [
55
68
  {
@@ -60,9 +73,9 @@ module Kumonos
60
73
  stat_prefix: 'egress_http',
61
74
  access_log: [{ path: access_log_path }],
62
75
  rds: {
63
- cluster: ds.cluster.name,
76
+ cluster: discovery_service.cluster.name,
64
77
  route_config_name: DEFAULT_ROUTE_NAME,
65
- refresh_delay_ms: ds.refresh_delay_ms
78
+ refresh_delay_ms: discovery_service.refresh_delay_ms
66
79
  },
67
80
  filters: [{ type: 'decoder', name: 'router', config: {} }]
68
81
  }
@@ -75,7 +88,15 @@ module Kumonos
75
88
  DiscoverService = Struct.new(:refresh_delay_ms, :cluster) do
76
89
  class << self
77
90
  def build(h)
78
- new(h.fetch('refresh_delay_ms'), Cluster.build(h.fetch('cluster')))
91
+ cluster = Cluster.new(
92
+ 'discovery_service',
93
+ 'strict_dns',
94
+ h.fetch('tls'),
95
+ h.fetch('connect_timeout_ms'),
96
+ 'round_robin',
97
+ [{ 'url' => "tcp://#{h.fetch('lb')}" }]
98
+ )
99
+ new(h.fetch('refresh_delay_ms'), cluster)
79
100
  end
80
101
  end
81
102
 
@@ -1,3 +1,3 @@
1
1
  module Kumonos
2
- VERSION = '0.9.3'.freeze
2
+ VERSION = '0.10.0'.freeze
3
3
  end
@@ -6,171 +6,108 @@
6
6
  "additionalProperties": true,
7
7
  "required": [
8
8
  "version",
9
- "ds",
10
9
  "listener",
11
- "admin"
10
+ "admin",
11
+ "discovery_service"
12
12
  ],
13
13
  "properties": {
14
14
  "version": {
15
15
  "type": "integer",
16
16
  "id": "/properties/version"
17
17
  },
18
- "ds": {
18
+ "listener": {
19
19
  "type": "object",
20
- "id": "/properties/ds",
20
+ "id": "/properties/listener",
21
21
  "additionalProperties": false,
22
22
  "required": [
23
- "refresh_delay_ms",
24
- "cluster"
23
+ "address",
24
+ "access_log_path"
25
25
  ],
26
26
  "properties": {
27
- "refresh_delay_ms": {
28
- "type": "integer",
29
- "id": "/properties/ds/properties/refresh_delay_ms"
27
+ "address": {
28
+ "type": "string",
29
+ "id": "/properties/listener/properties/address"
30
30
  },
31
- "cluster": {
32
- "type": "object",
33
- "id": "/properties/ds/properties/cluster",
34
- "additionalProperties": false,
35
- "required": [
36
- "name",
37
- "type",
38
- "tls",
39
- "connect_timeout_ms",
40
- "lb_type",
41
- "hosts"
42
- ],
43
- "properties": {
44
- "name": {
45
- "type": "string",
46
- "id": "/properties/ds/properties/cluster/properties/name"
47
- },
48
- "type": {
49
- "type": "string",
50
- "id": "/properties/ds/properties/cluster/properties/type"
51
- },
52
- "tls": {
53
- "type": "boolean",
54
- "id": "/properties/ds/properties/cluster/properties/tls"
55
- },
56
- "connect_timeout_ms": {
57
- "type": "integer",
58
- "id": "/properties/ds/properties/cluster/properties/connect_timeout_ms"
59
- },
60
- "lb_type": {
61
- "type": "string",
62
- "id": "/properties/ds/properties/cluster/properties/lb_type"
63
- },
64
- "hosts": {
65
- "type": "array",
66
- "id": "/properties/ds/properties/cluster/properties/hosts",
67
- "items": {
68
- "type": "object",
69
- "id": "/properties/ds/properties/cluster/properties/hosts/items",
70
- "additionalProperties": false,
71
- "required": [
72
- "url"
73
- ],
74
- "properties": {
75
- "url": {
76
- "type": "string",
77
- "id": "/properties/ds/properties/cluster/properties/hosts/items/properties/url"
78
- }
79
- }
80
- }
81
- }
82
- }
31
+ "access_log_path": {
32
+ "type": "string",
33
+ "id": "/properties/listener/properties/access_log_path"
83
34
  }
84
35
  }
85
36
  },
86
- "statsd": {
37
+ "admin": {
87
38
  "type": "object",
88
- "id": "/properties/statsd",
39
+ "id": "/properties/admin",
89
40
  "additionalProperties": false,
90
41
  "required": [
91
- "name",
92
- "connect_timeout_ms",
93
- "type",
94
- "tls",
95
- "lb_type",
96
- "hosts"
42
+ "address",
43
+ "access_log_path"
97
44
  ],
98
45
  "properties": {
99
- "name": {
100
- "type": "string",
101
- "id": "/properties/statsd/properties/name"
102
- },
103
- "connect_timeout_ms": {
104
- "type": "integer",
105
- "id": "/properties/statsd/properties/connect_timeout_ms"
106
- },
107
- "type": {
46
+ "address": {
108
47
  "type": "string",
109
- "id": "/properties/statsd/properties/type"
110
- },
111
- "tls": {
112
- "type": "boolean",
113
- "id": "/properties/statsd/properties/tls"
48
+ "id": "/properties/admin/properties/address"
114
49
  },
115
- "lb_type": {
50
+ "access_log_path": {
116
51
  "type": "string",
117
- "id": "/properties/statsd/properties/lb_type"
118
- },
119
- "hosts": {
120
- "type": "array",
121
- "id": "/properties/statsd/properties/hosts",
122
- "items": {
123
- "type": "object",
124
- "id": "/properties/statsd/properties/hosts/items",
125
- "additionalProperties": false,
126
- "required": [
127
- "url"
128
- ],
129
- "properties": {
130
- "url": {
131
- "type": "string",
132
- "id": "/properties/statsd/properties/hosts/items/properties/url"
133
- }
134
- }
135
- }
52
+ "id": "/properties/admin/properties/access_log_path"
136
53
  }
137
54
  }
138
55
  },
139
- "listener": {
56
+ "discovery_service": {
140
57
  "type": "object",
141
- "id": "/properties/listener",
58
+ "id": "/properties/discovery_service",
142
59
  "additionalProperties": false,
143
60
  "required": [
144
- "address",
145
- "access_log_path"
61
+ "lb",
62
+ "tls",
63
+ "refresh_delay_ms",
64
+ "connect_timeout_ms"
146
65
  ],
147
66
  "properties": {
148
- "address": {
67
+ "lb": {
149
68
  "type": "string",
150
- "id": "/properties/listener/properties/address"
69
+ "id": "/properties/discovery_service/properties/properties/lb"
151
70
  },
152
- "access_log_path": {
153
- "type": "string",
154
- "id": "/properties/listener/properties/access_log_path"
71
+ "tls": {
72
+ "type": "boolean",
73
+ "id": "/properties/discovery_service/properties/properties/tls"
74
+ },
75
+ "refresh_delay_ms": {
76
+ "type": "integer",
77
+ "id": "/properties/discovery_service/properties/refresh_delay_ms"
78
+ },
79
+ "connect_timeout_ms": {
80
+ "type": "integer",
81
+ "id": "/properties/discovery_service/properties/properties/connect_timeout_ms"
155
82
  }
156
83
  }
157
84
  },
158
- "admin": {
85
+ "statsd": {
159
86
  "type": "object",
160
- "id": "/properties/admin",
87
+ "id": "/properties/statsd",
161
88
  "additionalProperties": false,
162
89
  "required": [
163
90
  "address",
164
- "access_log_path"
91
+ "tls",
92
+ "type",
93
+ "connect_timeout_ms"
165
94
  ],
166
95
  "properties": {
167
96
  "address": {
168
97
  "type": "string",
169
- "id": "/properties/admin/properties/address"
98
+ "id": "/properties/statsd/properties/address"
170
99
  },
171
- "access_log_path": {
100
+ "tls": {
101
+ "type": "boolean",
102
+ "id": "/properties/statsd/properties/tls"
103
+ },
104
+ "type": {
172
105
  "type": "string",
173
- "id": "/properties/admin/properties/access_log_path"
106
+ "id": "/properties/statsd/properties/type"
107
+ },
108
+ "connect_timeout_ms": {
109
+ "type": "integer",
110
+ "id": "/properties/statsd/properties/connect_timeout_ms"
174
111
  }
175
112
  }
176
113
  }
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: kumonos
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.9.3
4
+ version: 0.10.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Taiki Ono
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2017-11-17 00:00:00.000000000 Z
11
+ date: 2017-11-20 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: json-schema
@@ -159,7 +159,7 @@ files:
159
159
  - bin/setup
160
160
  - bump
161
161
  - example/book.yml
162
- - example/envoy.json
162
+ - example/envoy_config.yml
163
163
  - example/example-with-tls.yml
164
164
  - exe/kumonos
165
165
  - exe/kumonos-relay
data/example/envoy.json DELETED
@@ -1,38 +0,0 @@
1
- {
2
- "version": 1,
3
- "ds": {
4
- "refresh_delay_ms": 30000,
5
- "cluster": {
6
- "name": "ds",
7
- "type": "strict_dns",
8
- "tls": false,
9
- "connect_timeout_ms": 1000,
10
- "lb_type": "round_robin",
11
- "hosts": [
12
- {
13
- "url": "tcp://nginx:80"
14
- }
15
- ]
16
- }
17
- },
18
- "statsd": {
19
- "name": "statsd",
20
- "connect_timeout_ms": 1000,
21
- "type": "strict_dns",
22
- "tls": false,
23
- "lb_type": "round_robin",
24
- "hosts": [
25
- {
26
- "url": "tcp://relay:2000"
27
- }
28
- ]
29
- },
30
- "listener": {
31
- "address": "tcp://0.0.0.0:9211",
32
- "access_log_path": "/dev/stdout"
33
- },
34
- "admin": {
35
- "address": "tcp://0.0.0.0:9901",
36
- "access_log_path": "/dev/stdout"
37
- }
38
- }