dendrite 0.4.3 → 0.4.4

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: e7d3f42a77f2e3b124d3828908b2c5d01ff92c74
4
- data.tar.gz: 98b1fe74cf265e61713202a91142aaee3914288c
3
+ metadata.gz: bad4d18d07075176dbe3c2b022d5e4b7388815ec
4
+ data.tar.gz: 3988a55003746c5af19ac0e948ca672cfedcc228
5
5
  SHA512:
6
- metadata.gz: 4be8c621a93637efd6654bad84bb542ad0b979d5d8ab968e3420707e6acd3b14544a8481ff21e1fcfda1736ce2aaa2dfdb0cd1d95b5ddda24b0232c266d544f4
7
- data.tar.gz: 9443196455dc1b10152091ac67a7220bddff4bb9d6ee77f67468fe0a3ee638116c9684036e8b5bfbe1587d6abbdbffdbe932fbe7289ff06e99c18c4c8750b2bc
6
+ metadata.gz: e41d4dc75c1b1c57685bd957c214e84fed1b1e42d9a279faac85e204981391631ec9c7781965d68a34c20bb66d6e9d9c3b68275f5dddacb23950009039bbfe1a
7
+ data.tar.gz: d2a2d7f76f2f66c32289cfbfb8c794e894cd70934dbb1301375561b45356c78230c2fc025092a865c74d167bb31990fe220aa7451ae9f21500ce45e64240303a
@@ -0,0 +1,18 @@
1
+ #!/usr/bin/env ruby
2
+ require 'dendrite'
3
+ require 'optparse'
4
+
5
+ options = {}
6
+ OptionParser.new do |opts|
7
+ opts.banner = "Usage: register [options]"
8
+ opts.on("-s", "--service SERVICE_NAME", "service name") do |v|
9
+ options[:service_name] = v
10
+ end
11
+
12
+ opts.on("-c", "--config CONFIG_FILE", "config file") do |v|
13
+ options[:config] = v
14
+ end
15
+ end.parse!
16
+ Dendrite::Config.load(source: options[:config])
17
+ graph = Dendrite::IO.load(source: Dendrite::Config.services_source)
18
+ puts graph[options[:service_name]].to_h.to_json
@@ -14,6 +14,9 @@ subcomponents:
14
14
  ports:
15
15
  loadbalancer_port: 8082
16
16
  service_port: 8080
17
+ telemetry:
18
+ health_url: /
19
+ notification_email: foo@bar.com
17
20
  dependencies:
18
21
  - component: cams
19
22
  subcomponent: cat
@@ -31,6 +31,12 @@ module Dendrite
31
31
  end
32
32
  end
33
33
 
34
+ if telemetry && telemetry.invalid?
35
+ telemetry.errors.each do |key, value|
36
+ errors.add "telemetry_#{key}", value
37
+ end
38
+ end
39
+
34
40
  return errors.count == 0
35
41
  end
36
42
  end
@@ -39,6 +45,15 @@ module Dendrite
39
45
  include ActiveModel::Validations
40
46
  prepend Validator
41
47
 
48
+ VALID_EMAIL_REGEX = /\A[\w+\-.]+@[a-z\d\-]+(\.[a-z]+)*\.[a-z]+\z/i
49
+
50
+ Telemetry = Struct.new(:health_url, :notification_email) do
51
+ include ActiveModel::Validations
52
+ validates_presence_of :health_url
53
+ validates_presence_of :notification_email
54
+ validates :notification_email, format: { with: ServiceNode::VALID_EMAIL_REGEX, message: "invalid email format" }
55
+ end
56
+
42
57
  Port = Struct.new(:name, :port) do
43
58
  include ActiveModel::Validations
44
59
  validates_presence_of :name
@@ -73,10 +88,8 @@ module Dendrite
73
88
  validates_presence_of :package
74
89
  end
75
90
 
76
- VALID_EMAIL_REGEX = /\A[\w+\-.]+@[a-z\d\-]+(\.[a-z]+)*\.[a-z]+\z/i
77
-
78
91
  attr_reader :organization, :component, :lead_email, :team_email,
79
- :type, :deploy, :scale, :ports, :dependencies
92
+ :type, :deploy, :scale, :ports, :dependencies, :telemetry
80
93
  # :name is set but magically
81
94
 
82
95
  validates_presence_of :organization, :component, :lead_email, :team_email,
@@ -101,6 +114,8 @@ module Dendrite
101
114
  @deploy = Deploy.new(v[:repository], v[:package]) if v != nil
102
115
  when :scale
103
116
  @scale = Scale.new(v[:max_instance_count], v[:min_instance_count]) if v != nil
117
+ when :telemetry
118
+ @telemetry = Telemetry.new(v[:health_url], v[:notification_email]) if v != nil
104
119
  else
105
120
  instance_variable_set("@#{k}", v)
106
121
  end
@@ -127,5 +142,23 @@ module Dendrite
127
142
  def add_dependency(service:, latency:)
128
143
  @dependencies[service.name] = Dependency.new(service, latency)
129
144
  end
145
+
146
+ def to_h
147
+ data = {
148
+ organization: organization,
149
+ component: component,
150
+ name: real_name,
151
+ complete_name: name,
152
+ lead_email: lead_email,
153
+ team_email: team_email,
154
+ type: type,
155
+ ports: ports.values.collect(&:to_h),
156
+ dependencies: dependencies.keys
157
+ }
158
+ data.merge!({deploy: deploy.to_h}) if deploy
159
+ data.merge!({scale: scale.to_h}) if scale
160
+ data.merge!({telemetry: telemetry.to_h}) if telemetry
161
+ data
162
+ end
130
163
  end
131
164
  end
@@ -1,3 +1,3 @@
1
1
  module Dendrite
2
- VERSION = "0.4.3"
2
+ VERSION = "0.4.4"
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: dendrite
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.4.3
4
+ version: 0.4.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - Yagnik
@@ -85,6 +85,7 @@ email:
85
85
  - yagnikkhanna@gmail.com
86
86
  executables:
87
87
  - add_proxy
88
+ - metadata
88
89
  - register
89
90
  extensions: []
90
91
  extra_rdoc_files: []
@@ -96,6 +97,7 @@ files:
96
97
  - README.md
97
98
  - Rakefile
98
99
  - bin/add_proxy
100
+ - bin/metadata
99
101
  - bin/register
100
102
  - conf/config.yaml
101
103
  - conf/services/service.yml