kumonos 0.16.0 → 0.17.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: 7552a947b18df88ba3119cc25787a74b7b11b9f9b0dc8595ab0ede425d37af5b
4
- data.tar.gz: b259c3ab474176183c27fd8bb21e8b1588f482a85ebd045b68c738f9c7f9e503
3
+ metadata.gz: 529353de6d713d922bfa8a74af3e04166ecbb949755c945014c51fd5bcd0ed24
4
+ data.tar.gz: c73615662f4f8f87dcf82c0505d2581ddccf2a9b27c318b84dcd2590ba070cea
5
5
  SHA512:
6
- metadata.gz: 31d92d52e20390bca01ff44c9384732b6e7322160ea4d2cea09adb172fefe178dc5af4ba2036965ba9dd37abc382635baf8cd4475aeacf34809a8132e22bfdef
7
- data.tar.gz: 3861238172661df1e09af4bf8d79618ad307c814b5bc0f0174ff3c863c7cd97cce02c2bb0d53e65d0091a0e46cda997094a301560c4a8ca6a9a65d22f1a2fa84
6
+ metadata.gz: 1c19e7a8a6d07d450f7b930f7bddf2eb5961d09e177ac42817bc8cf540159354f12af12786f304a0a04ac5821ea6ea61cc973dedea3f7030f91abad9ce8f2d3c
7
+ data.tar.gz: 727084fb53fb46d101e090903bf26ef52f098fb2aad16b90db0cc3405a2bbc77fbf34de7d89ecf8cf477e1a936d7876d4e23a35d07c87c41fef06b6cb0f1b09c
@@ -0,0 +1,27 @@
1
+ local circuit_breaker = import 'circuit_breaker.libsonnet';
2
+ local routes = import 'routes.libsonnet';
3
+
4
+ {
5
+ version: 1,
6
+ dependencies: [
7
+ {
8
+ name: "user",
9
+ cluster_name: "user-development",
10
+ lb: "user-app:8080",
11
+ host_header: "user-service",
12
+ tls: false,
13
+ connect_timeout_ms: 250,
14
+ circuit_breaker: circuit_breaker,
15
+ routes: [routes.root],
16
+ },
17
+ {
18
+ name: "ab-testing",
19
+ cluster_name: "ab-testing-development",
20
+ sds: true,
21
+ tls: false,
22
+ connect_timeout_ms: 250,
23
+ circuit_breaker: circuit_breaker,
24
+ routes: [routes.root],
25
+ },
26
+ ],
27
+ }
@@ -0,0 +1,5 @@
1
+ {
2
+ max_connections: 64,
3
+ max_pending_requests: 128,
4
+ max_retries: 3,
5
+ }
@@ -0,0 +1,11 @@
1
+ {
2
+ root: {
3
+ prefix: "/",
4
+ timeout_ms: 3000,
5
+ retry_policy: {
6
+ retry_on: "5xx,connect-failure,refused-stream",
7
+ num_retries: 3,
8
+ per_try_timeout_ms: 1000,
9
+ },
10
+ },
11
+ }
data/exe/kumonos CHANGED
@@ -5,6 +5,9 @@ $LOAD_PATH.unshift(File.expand_path('../lib', __dir__))
5
5
  require 'kumonos'
6
6
  require 'thor'
7
7
 
8
+ require 'json'
9
+ require 'jsonnet'
10
+
8
11
  # KumonosCli
9
12
  class KumonosCli < Thor
10
13
  def self.exit_on_failure?
@@ -17,7 +20,7 @@ class KumonosCli < Thor
17
20
  method_option :'service-node', desc: 'Service node', required: true, type: :string
18
21
  def envoy(path)
19
22
  validate_path!(path)
20
- definition = YAML.load_file(path)
23
+ definition = load_definition(path)
21
24
  validate_envoy_definition!(definition, path)
22
25
 
23
26
  config = Kumonos::Envoy.generate(
@@ -35,7 +38,7 @@ class KumonosCli < Thor
35
38
  validate_path!(filepath)
36
39
  validate_path!(output_dir)
37
40
 
38
- definition = YAML.load_file(filepath)
41
+ definition = load_definition(filepath)
39
42
  validate_service_definition!(definition, filepath)
40
43
  json = JSON.dump(Kumonos::Clusters.generate(definition))
41
44
 
@@ -50,7 +53,7 @@ class KumonosCli < Thor
50
53
  validate_path!(filepath)
51
54
  validate_path!(output_dir)
52
55
 
53
- definition = YAML.load_file(filepath)
56
+ definition = load_definition(filepath)
54
57
  validate_service_definition!(definition, filepath)
55
58
  json = JSON.dump(Kumonos::Routes.generate(definition))
56
59
 
@@ -60,15 +63,15 @@ class KumonosCli < Thor
60
63
 
61
64
  desc 'init NAME', 'Generate a service definition'
62
65
  def init(name)
63
- definition = YAML.load_file(File.expand_path('../example/book.yml', __dir__))
66
+ definition = load_definition(File.expand_path('../example/book.jsonnet', __dir__))
64
67
  definition['dependencies'] = definition.fetch('dependencies')[0..0]
65
68
  dep = definition['dependencies'][0]
66
69
  dep['name'] = 'target-service-name'
67
70
  dep['cluster_name'] = 'target-service-name-staging'
68
71
  dep['lb'] = 'hostname-for-load-balancer:port'
69
72
  dep.delete('sds')
70
- path = "#{name}.yml"
71
- File.open(path, 'w') { |f| YAML.dump(definition, f) }
73
+ path = "#{name}.jsonnet"
74
+ File.write(path, JSON.pretty_generate(definition))
72
75
  puts path
73
76
  end
74
77
 
@@ -99,6 +102,16 @@ class KumonosCli < Thor
99
102
  warn("The schema file is #{schema_path}")
100
103
  exit 1
101
104
  end
105
+
106
+ def load_definition(path)
107
+ if path.end_with?('.jsonnet')
108
+ Jsonnet.load(path)
109
+ elsif path.end_with?('.yml', '.yaml')
110
+ YAML.load_file(path)
111
+ else
112
+ raise "Unknown extension given, expected '.jsonnet', '.yml' or 'yaml': #{path}"
113
+ end
114
+ end
102
115
  end
103
116
 
104
117
  KumonosCli.start(ARGV)
data/kumonos.gemspec CHANGED
@@ -21,6 +21,7 @@ Gem::Specification.new do |spec|
21
21
  spec.require_paths = ['lib']
22
22
 
23
23
  spec.add_dependency 'json-schema'
24
+ spec.add_dependency 'jsonnet'
24
25
  spec.add_dependency 'thor'
25
26
  spec.add_development_dependency 'bundler'
26
27
  spec.add_development_dependency 'grpc'
@@ -1,3 +1,3 @@
1
1
  module Kumonos
2
- VERSION = '0.16.0'.freeze
2
+ VERSION = '0.17.0'.freeze
3
3
  end
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.16.0
4
+ version: 0.17.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: 2018-03-27 00:00:00.000000000 Z
11
+ date: 2018-04-11 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: json-schema
@@ -24,6 +24,20 @@ dependencies:
24
24
  - - ">="
25
25
  - !ruby/object:Gem::Version
26
26
  version: '0'
27
+ - !ruby/object:Gem::Dependency
28
+ name: jsonnet
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - ">="
32
+ - !ruby/object:Gem::Version
33
+ version: '0'
34
+ type: :runtime
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - ">="
39
+ - !ruby/object:Gem::Version
40
+ version: '0'
27
41
  - !ruby/object:Gem::Dependency
28
42
  name: thor
29
43
  requirement: !ruby/object:Gem::Requirement
@@ -171,9 +185,11 @@ files:
171
185
  - bin/console
172
186
  - bin/setup
173
187
  - bump
174
- - example/book.yml
188
+ - example/book.jsonnet
189
+ - example/circuit_breaker.libsonnet
175
190
  - example/envoy_config.yml
176
191
  - example/example-with-tls.yml
192
+ - example/routes.libsonnet
177
193
  - exe/kumonos
178
194
  - kumonos.gemspec
179
195
  - lib/kumonos.rb
@@ -205,7 +221,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
205
221
  version: '0'
206
222
  requirements: []
207
223
  rubyforge_project:
208
- rubygems_version: 2.7.3
224
+ rubygems_version: 2.7.6
209
225
  signing_key:
210
226
  specification_version: 4
211
227
  summary: A "control plane" for Microservices "service mesh".
data/example/book.yml DELETED
@@ -1,37 +0,0 @@
1
- # A example definition for book service.
2
- # The book service uses user service and ab-testing service.
3
- version: 1
4
- dependencies:
5
- - name: 'user'
6
- cluster_name: 'user-development'
7
- lb: 'user-app:8080'
8
- host_header: 'user-service'
9
- tls: false
10
- connect_timeout_ms: 250
11
- circuit_breaker:
12
- max_connections: 64
13
- max_pending_requests: 128
14
- max_retries: 3
15
- routes:
16
- - prefix: '/'
17
- timeout_ms: 3000
18
- retry_policy:
19
- retry_on: '5xx,connect-failure,refused-stream'
20
- num_retries: 3
21
- per_try_timeout_ms: 1000
22
- - name: 'ab-testing'
23
- cluster_name: 'ab-testing-development'
24
- sds: true
25
- tls: false
26
- connect_timeout_ms: 250
27
- circuit_breaker:
28
- max_connections: 64
29
- max_pending_requests: 128
30
- max_retries: 3
31
- routes:
32
- - prefix: '/'
33
- timeout_ms: 3000
34
- retry_policy:
35
- retry_on: '5xx,connect-failure,refused-stream'
36
- num_retries: 3
37
- per_try_timeout_ms: 1000