consul-templaterb 1.21.4 → 1.21.5

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: e21590daefa93a69c9c00cd3acc6ebf0444a1a84d6bd9f1504c76484b4b97f0a
4
- data.tar.gz: 290cbbdd8d86978a93b0c698d75d1c4822b8a2b521e32d7f93df96caac756d31
3
+ metadata.gz: 5fa40822c8a08d6cef1fff5fc846759ea9134d4b0faba09b2f0d986f3cf27f31
4
+ data.tar.gz: 25991106429db5b863c56f4ab136a99e2e58cfcd6529c84f5a6f15050d406184
5
5
  SHA512:
6
- metadata.gz: 41ceec7b88410c5533cc073ec65f396cd6cf44de4a0c373465d3ae2931f024b2e65c1b88673b83c976d80fca5c53a0e28201a752681f21673fb87bcfdba1dfa9
7
- data.tar.gz: 256c721efaa834afcfde8d3d7aadd042a2b73dc1d4894f8d657fc02e4883cbbb0a0a6d12f8a8c5c082d7207b704dd5a8214546955ae8058c9fb9e0db02722d1c
6
+ metadata.gz: d1d606bdb1129c6cc1bea6b62d824f0d5fdbc76620f228f1eb5eb3a89fb14d6b6b568b5189c4ca2e48189fa5a812cdccdc24b1d794ef7f3f724ff8b9af8ce5dd
7
+ data.tar.gz: 68550789a4a1d95a754329e57f41c24d1b2976c9f32d07f1414d40abc7f014208f4adc59043653b80e58abe567f87d6d31cdf3015e44a12bc8c6a9c584d025f8
data/CHANGELOG.md CHANGED
@@ -2,6 +2,10 @@
2
2
 
3
3
  ## (UNRELEASED)
4
4
 
5
+ ## 1.21.5 (December 6, 2019)
6
+
7
+ * Added clean() method in nodes.js to allow nexw behaviors
8
+
5
9
  ## 1.21.4 (November 28, 2019)
6
10
 
7
11
  * added 2 decorators `navBarDecorator` and `fetchedResponseDecorator`
data/CONTRIBUTING.md CHANGED
@@ -1,5 +1,9 @@
1
1
  # How to contribute to Consul-Templaterb ?
2
2
 
3
+ ## Architecxture Overview
4
+
5
+ Please read [INTERNALS.md](INTERNALS.md) to understand how it works.
6
+
3
7
  ## Samples
4
8
 
5
9
  The [samples/](samples/) directory contains lots of useable templates that might help others using your new features.
data/INTERNALS.md ADDED
@@ -0,0 +1,47 @@
1
+ # consul-templaterb Internal Architecture Overview
2
+
3
+ ## Consul basics
4
+
5
+ `consul-templaterb` is a ruby library (or `GEM`) with a single binary that does render `.erb` files based on Consul exposed endpoints.
6
+
7
+ Consul is a kind of distributed K/V tree store that exposes most of his APIs using HTTP endpoints with a way to watch for changes based on an Index. Each part of the Consul Tree has its own Index reflecting the last id of transaction for this
8
+ part of the tree. It means that Consul has a kind of transaction ID for each subtree of the data.
9
+
10
+ Consul also exposes some specific endpoints to get some discovery specific endpoints (eg: `/v1/catalog/services` to get
11
+ the list of services registered in the cluster).
12
+
13
+ For each endpoint, `consul-templaterb` performs a watch by getting information about the last transaction on this endpoints, storing it locally and watching at Consul to get updates about the data within this endpoint.
14
+
15
+ ## How it works
16
+
17
+ There is a loop in the engine, every second, all templates are rendered using the `ERB` template engine.
18
+
19
+ Each template is assigned to a `ConsulTemplateRender` object that keeps tracks of changes on disk of template (in order
20
+ to be able to hot-reload templates) as well as monitoring if the template is completely rendered, aka all data from
21
+ Consul is properly retrieved and consistent.
22
+
23
+ At each rendering, each template using a Consul Endpoint (for instance, calling `datacenters()`) does register itself
24
+ in `EndPointsManager`. If the endpoint is already registered, fetch the result if available and return the value, if not,
25
+ the endpoint is tagged as dirty. When the rendering of a template is completed, a check is performed to see if some endpoints used by the template are still marked as dirty. Being dirty means that some data from Consul is missing, so
26
+ that the result is not the definitive one. If no endpoint is dirty, then the result of template can be rendered on disk
27
+ and template is complete.
28
+
29
+ At startup, in order to converge faster, templates are rendered more quickly that every 1s to speed up startup time for first convergence, meaning that the delay between each rendering of template might be very fast, especially at startup (so, DO NOT USE Ruby I/O in templates unless you really know what you are doing)
30
+
31
+ ### EndPointsManager
32
+
33
+ `EndPointsManager` is the object responsible of keeping track the endpoints (basically the I/O) of the whole library.
34
+ When a new Consul endpoint is added by a template, it is registered in that object. Each time a template is rendered,
35
+ all the endpoints are marked as used. When some endpoints are not used for a while (a few rendering loops), the
36
+ `EndPointsManager` will garbage collect those endpoints.
37
+
38
+ ### ConsulTemplateEngine
39
+
40
+ When `consul-templaterb` starts, it creates an [ConsulTemplateEngine](lib/consul/async/consul_template_engine.rb) that
41
+ aggregates all options, template files and parameters. The engine then starts a loop running every second (this can be changed) that:
42
+ * perform a rendering of each of the `.erb` template files using a `ConsulTemplateRender` object
43
+ * when all template are rendered the first time, will start some program(s) if specified (the `--exec` parameters)
44
+
45
+ ### ConsulTemplateRender
46
+
47
+ This object keeps track of template, its last state (rendered or not), and whether the file template needs to be reloaded (aka if file has been modified on filesystem).
@@ -1,5 +1,5 @@
1
1
  module Consul
2
2
  module Async
3
- VERSION = '1.21.4'.freeze
3
+ VERSION = '1.21.5'.freeze
4
4
  end
5
5
  end
@@ -15,6 +15,10 @@ class ConsulNodesManager extends ConsulUIManager {
15
15
  async initResource(data) {
16
16
  this.mainSelector.initSelector(data["nodes"]);
17
17
  }
18
+
19
+ async clean() {
20
+ this.mainSelector.initSelector({});
21
+ }
18
22
  }
19
23
 
20
24
  class NodeMainSelector extends MainSelector {
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: consul-templaterb
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.21.4
4
+ version: 1.21.5
5
5
  platform: ruby
6
6
  authors:
7
7
  - SRE Core Services
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2019-11-28 00:00:00.000000000 Z
11
+ date: 2019-12-06 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: em-http-request
@@ -172,6 +172,7 @@ files:
172
172
  - CONTRIBUTING.md
173
173
  - Dockerfile
174
174
  - Gemfile
175
+ - INTERNALS.md
175
176
  - LICENSE.txt
176
177
  - README.md
177
178
  - Rakefile