consul-templaterb 1.8.5 → 1.8.6

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: d17ec48b3c3611a4e49e13ef9daaeeb44f3f6cc02768ccdcd579e64c2af1a7ec
4
- data.tar.gz: 59300692c12bacfa4e232679fc7568437ebf9fd3ca977161f702b2f1f4666b76
3
+ metadata.gz: 19a273b406bb2bc529957446c5555ffd0ec2792dffc05d6aeb89b26999f474a6
4
+ data.tar.gz: d720a5cd38cc5ce993bd952690ac893ed011c661bbdffe7830d1ab15993710a5
5
5
  SHA512:
6
- metadata.gz: b3356add5c81df85061ed0810ea6775252044e771ca10cce3cec5a60fc22c9e1f2cd5e60707d90c4e939b061baa3c8c97155ffe7e3fa41b16a195730f3ebbd98
7
- data.tar.gz: 6f6b3a75a175d7314f8f7b8878c161d283500011beb7b4e21ae9c1a410d326a15ca7d83e135ed4a0a13705995053940036689a6b4cb4f2d249494881013466b1
6
+ metadata.gz: 056bcf7ee589aa4021ff6eaa83db44fa91fa9ef82f392165e42a06172e4a1502a23a9904cd3f46672b26ed20f707ae549fb86c51d226e90e51d8a052355509ed
7
+ data.tar.gz: 2a62c016f97c615e8f77b400b8bfc5f60ad0a76b64b7c147f8e03fc6dd130de672b954b8c8378ccf9fb5a829b63735c13cee97df9cef84f7397b6bdbc058396c
@@ -8,8 +8,6 @@ deploy:
8
8
  api_key:
9
9
  secure: l78H6Ow9HCeEz0hcAP2XCXaGGBNRXZ/QLFPNzwyNmHToko9WqZj6mbiNIcVwZ8aCcZEzFmtcB7m1lC1l+mvot3Snfh4OUErK7EXMLiNxUWybtA4qJqmsb2J8JGS69pTohPKagi1YyRbyVs2tJpM5OVazcNxEQDAVkWVxJuPVz6tsn4rXZsL77nTSVyB6YGKgguRGhtS/3M0ufk1ymOpuk8pxXKaotlYGRXmht2OHW+FDQczTMgqu6jiZubjWlNHVxtYn+CsLYNj1BswzD6fF1uous6nchV0if2QW5N4OJVyZCx3yEQ0RswfI8G1kG/Jm8wd2lSknY2wpnd1qkRnAcFlKBpUv8aQd6SdbSO84GTAOvucgK7Mcf0LRvYSE2FyagaAPFSfMybWd+GS26g5AuRPpkhtsS9ijfdIzpudiF18pvnJ+wQj+hWM/THWowYNyKv9NeckxdrULaHPisA346r5eM/EADOhyEUtPm11PFgcheGjff1H4qXGc9gcm50u6mNNHkWv38oGhAPpRk/bU7qybTKqRKNGWGP0MiT4WVIFXp62/JMY7AmufOdJx5Ca5JVsaWoN4fsS9r3+R+FxvRtV9NOrRJVKKaQhzi4UHEUDQ2hQjpLDijD5L0vUsl6arl+nufTt5G5jp9QvdY7fhYT1mpGgWj0hTBd8Pxsl3N8U=
10
10
  gem: consul-templaterb
11
- edge:
12
- branch: v1.8.47
13
11
  on:
14
12
  tags: true
15
13
  repo: criteo/consul-templaterb
@@ -2,6 +2,13 @@
2
2
 
3
3
  ## (UNRELEASED)
4
4
 
5
+ ## 1.8.6 (December 19, 2018)
6
+
7
+ OPTIMIZATIONS:
8
+
9
+ * Full rewrite of filtering of consul-timeline to allow handling
10
+ history of 100k+ records
11
+
5
12
  ## 1.8.5 (December 18, 2018)
6
13
 
7
14
  OPTIMIZATIONS:
@@ -1,5 +1,5 @@
1
1
  module Consul
2
2
  module Async
3
- VERSION = '1.8.5'.freeze
3
+ VERSION = '1.8.6'.freeze
4
4
  end
5
5
  end
@@ -16,15 +16,19 @@
16
16
  </div>
17
17
  </div>
18
18
  <div class="col-10 col-m-9">
19
- <div id="autorefresh">
20
- <input id="autorefresh-check" type="checkbox" checked><label for="autorefresh-check">Autorefresh</label><br/>
21
- <label for="autorefresh-check">Max Rows:</label>
22
- <input id="maxRows" style="width: 5em;" type="number" min="100" max="<%= (ENV['CONSUL_TIMELINE_BUFFER'] || 10000) %>" step="100" value="5000"/>
23
- </div>
24
19
  <h2 class="text-center" id="service-title" style="clear:both"></h2>
25
20
  <div class="row mb-2">
26
21
  <div class="input-group float-left col-12">
27
22
  <input id="instance-filter" type="search" placeholder="filter events" class="form-control" />
23
+ <div class="input-group-append">
24
+ <div class="input-group-append">
25
+ <span class="input-group-text">
26
+ <input title="Auto-Refresh" id="autorefresh-check" type="checkbox" checked>&nbsp;
27
+ <span id="numRowsDisplayed" class="lookup badge badge-pill badge-primary">loading&hellip;</span>
28
+ </span>
29
+ </div>
30
+ <input id="maxRows" title="max rows to display" placeholder="max rows" style="width: 5em !important;" type="number" min="100" max="<%= (ENV['CONSUL_TIMELINE_BUFFER'] || 10000) %>" step="25" value="5000" class="form-control"/>
31
+ </div>
28
32
  </div>
29
33
  </div>
30
34
  <div id="instances-wrapper">
@@ -134,8 +134,6 @@ class ServiceTimeline {
134
134
  }
135
135
  setInterval(sT.reloadDataFromJSON, 10000);
136
136
  }, 150);
137
- } else {
138
- this.performFiltering($('#instance-filter')[0].value);
139
137
  }
140
138
  }
141
139
 
@@ -170,61 +168,6 @@ class ServiceTimeline {
170
168
  return span;
171
169
  }
172
170
 
173
- performFiltering(filterValue) {
174
- this.refreshTimeout = null;
175
- var matcher;
176
- try {
177
- matcher = new RegExp(filterValue);
178
- } catch (e) {
179
- var safeReg = filterValue.replace(/[-[\]{}()*+?.,\\^$|]/g, "\\$&")
180
- console.log("Failed to compile regexp for '" + filterValue + "', using strict lookup due to: " + e);
181
- matcher = new RegExp(safeReg);
182
- }
183
- console.log("Filtering on service", serviceTimeline.serviceInstanceFilter, " with ", matcher, "filterValue:=", filterValue);
184
- var isCorrectService = function(){ return true; };
185
- if (serviceTimeline.serviceInstanceFilter == 'All') {
186
- serviceTimeline.serviceInstanceFilter = '';
187
- }
188
- if (serviceTimeline.serviceInstanceFilter == ''){
189
- var stylesheet = document.getElementById('serviceCol');
190
- var txt = '';
191
- if (filterValue != '') {
192
- txt+='tr.filtered { display: none; }';
193
- }
194
- stylesheet.textContent = txt;
195
- } else {
196
- var stylesheet = document.getElementById('serviceCol');
197
- var txt = '.serviceCol';
198
- if (filterValue != '') {
199
- txt+=',tr.filtered'
200
- }
201
- for (var i in this.presentServices) {
202
- if (i != serviceTimeline.serviceInstanceFilter) {
203
- txt+=',tr.srv-'+i;
204
- }
205
- }
206
- stylesheet.textContent = txt + ' { display: none; }';
207
- isCorrectService = function(ui) { return ui.hasClass('srv-' + serviceTimeline.serviceInstanceFilter) };
208
- }
209
- if (filterValue != '') {
210
- $("#all-events > tbody").children('tr').each(function (){
211
- var ui = $(this);
212
- var shouldShow = isCorrectService(ui) && ui.children('.lookup').is(function (){
213
- var elem = $(this);
214
- if (elem[0].innerHTML.match(matcher)) {
215
- return true;
216
- }
217
- return false;
218
- });
219
- if (shouldShow) {
220
- ui.removeClass('filtered');
221
- } else {
222
- ui.addClass('filtered');
223
- }
224
- });
225
- }
226
- }
227
-
228
171
  doFilter() {
229
172
  var filterValue = $('#instance-filter')[0].value;
230
173
  if (this.refreshTimeout) {
@@ -232,7 +175,7 @@ class ServiceTimeline {
232
175
  this.refreshTimeout = null;
233
176
  }
234
177
  this.refreshTimeout = window.setTimeout(function(){
235
- serviceTimeline.performFiltering(filterValue);
178
+ serviceTimeline.displayEvents(false, filterValue);
236
179
  }, 16);
237
180
  }
238
181
 
@@ -286,48 +229,72 @@ class ServiceTimeline {
286
229
  }
287
230
 
288
231
  displayEvents(firstReload) {
232
+ var filterValue = $('#instance-filter')[0].value;
233
+ var serviceName = serviceTimeline.serviceInstanceFilter;
234
+ var serviceEvaluator = function(){return true};
235
+ if (serviceName != '' && serviceName != 'All') {
236
+ serviceEvaluator = function(e){ return e.service === serviceName }
237
+ }
289
238
  var maxRows = document.getElementById("maxRows").value;
290
239
  //$("#service-title").html(service['name']);
291
240
  var tableBody = $('#all-events > tbody');
292
241
  var startIndex = 0;
293
- if (firstReload || this.lastEntryLoaded == null) {
294
- tableBody.html("");
295
- } else {
296
- // We first try to find new entries...
297
- var lastDisplayedIndex = indexOfTimelineEvent(this.lastEntryLoaded);
298
- var newestIndexInNewDocument = "000";
299
- if (this.data.length > 0) {
300
- newestIndexInNewDocument = indexOfTimelineEvent(this.data[this.data.length - 1]);
301
- }
302
- if (lastDisplayedIndex >= newestIndexInNewDocument) {
303
- // Might happen when behind a VIP
304
- console.log("Skip reload, index: ", lastDisplayedIndex, ", new is ", newestIndexInNewDocument);
305
- return;
306
- } else {
307
- console.log("Index ", lastDisplayedIndex, " -> ", newestIndexInNewDocument);
242
+ var newDoc = document.createDocumentFragment();
243
+ var frag = document.createElement('tbody');
244
+ newDoc.appendChild(frag);
245
+ var filter = "";
246
+ var count = 0;
247
+ if (filterValue != ''){
248
+ var matcher;
249
+ try {
250
+ matcher = new RegExp(filterValue);
251
+ } catch (e) {
252
+ var safeReg = filterValue.replace(/[-[\]{}()*+?.,\\^$|]/g, "\\$&")
253
+ console.log("Failed to compile regexp for '" + filterValue + "', using strict lookup due to: " + e);
254
+ matcher = new RegExp(safeReg);
308
255
  }
309
- for (var i = 0 ; i < this.data.length; i++) {
310
- var e = this.data[i];
311
- if (lastDisplayedIndex < indexOfTimelineEvent(e)) {
312
- startIndex = i + 1;
313
- console.log('Resuming at ', startIndex, " with ", e);
314
- break;
256
+ var delegateServiceEvaluator = serviceEvaluator;
257
+ const fields = ['instance', 'service'];
258
+ const instance_info_fields = ['node', 'port'];
259
+ const check_fields = ['name', 'output'];
260
+ serviceEvaluator = function(e) {
261
+ var res = delegateServiceEvaluator(e);
262
+ if (!res) {
263
+ return false;
315
264
  }
265
+ for (var i = 0; i < fields.length; i++) {
266
+ var field = fields[i];
267
+ if (matcher.test(e[field])){
268
+ return true;
269
+ }
270
+ }
271
+ for (var i = 0; i < instance_info_fields.length; i++) {
272
+ var field = instance_info_fields[i];
273
+ if (matcher.test(e.instance_info[field])){
274
+ return true;
275
+ }
276
+ }
277
+ for (var checkId in e.instance_info.checks) {
278
+ if (matcher.test(checkId)) {
279
+ return true;
280
+ }
281
+ var check = e.instance_info.checks[checkId];
282
+ for (var i = 0; i < check_fields.length; i++) {
283
+ var field = check_fields[i];
284
+ if (matcher.test(check[field])){
285
+ return true;
286
+ }
287
+ }
288
+ }
289
+ return false;
316
290
  }
317
291
  }
318
- var frag = document.createDocumentFragment();
319
- var filter = "";
320
- var lastEntryFound = null;
321
- if (this.data.length > maxRows) {
322
- var remaining = this.data.length - startIndex;
323
- if (startIndex < remaining) {
324
- startIndex = this.data.length - maxRows;
325
- console.log('Skip first ', startIndex, " entries on ", this.data.length, " lines...");
326
- }
327
- }
328
- for (var i = startIndex ; i < this.data.length; i++) {
292
+ for (var i = this.data.length - 1 ; i >= 0 && count <= maxRows; i--) {
329
293
  var e = this.data[i];
330
- lastEntryFound = e;
294
+ if (!serviceEvaluator(e)) {
295
+ continue;
296
+ }
297
+ count++;
331
298
  var row = document.createElement('tr');
332
299
  row.setAttribute("class", 'srv-' + e.service);
333
300
  var timestamp;
@@ -413,22 +380,14 @@ class ServiceTimeline {
413
380
  }
414
381
  this.buildCell(row, 'td', 'ipercents', this.createBadge(percent + " %", clazz));
415
382
  }
416
- frag.prepend(row);
383
+ frag.append(row);
417
384
  }
385
+ $('#numRowsDisplayed').html(count + ' / ' + this.data.length);
418
386
  var tbody = tableBody[0];
419
- tbody.prepend(frag);
420
- this.lastEntryLoaded = lastEntryFound;
421
- console.log("Last entry loaded: ", indexOfTimelineEvent(this.lastEntryLoaded));
422
- var i = 0;
423
-
424
- var tbody = tableBody.children('tr').each (function() {
425
- i++;
426
- if (i > maxRows) {
427
- $(this).remove()
428
- }
429
- });
430
- if (i > maxRows) {
431
- console.log("Removed ", maxRows - i, " lines.")
387
+ tbody.parentNode.replaceChild(frag, tbody);
388
+ if (this.data.length > 1) {
389
+ this.lastEntryLoaded = this.data[this.data.length - 1];
390
+ console.log("Last entry loaded: ", indexOfTimelineEvent(this.lastEntryLoaded));
432
391
  }
433
392
  }
434
393
  }
@@ -61,7 +61,14 @@ class RingBuffer < Array
61
61
  super
62
62
  else
63
63
  shift
64
+ previous_e = last
65
+ after = []
66
+ while !previous_e.nil? && previous_e['idx'] > element['idx']
67
+ after << pop
68
+ previous_e = last
69
+ end
64
70
  push(element)
71
+ push after
65
72
  end
66
73
  end
67
74
 
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: consul-templaterb
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.8.5
4
+ version: 1.8.6
5
5
  platform: ruby
6
6
  authors:
7
7
  - SRE Core Services