Commit 5250ab85 authored by Alan Szlosek's avatar Alan Szlosek

remove minutely digest intervals, they are bad UX

parent d7f32033
Pipeline #15143826 passed with stage
in 1 minute and 3 seconds
...@@ -10,8 +10,6 @@ var debug = true; ...@@ -10,8 +10,6 @@ var debug = true;
// ISO-8601 format is: YYYY-MM-DDTHH:mm:ss.sssZ // ISO-8601 format is: YYYY-MM-DDTHH:mm:ss.sssZ
var digestPattern = /T\d\d:[012345]0:00.\d\d\dZ$/; var digestPattern = /T\d\d:[012345]0:00.\d\d\dZ$/;
var everyTenMinutes = new Harbinger.Digest( var everyTenMinutes = new Harbinger.Digest(
// evaluate every minute
false,
// pattern matches times every 10 minutes // pattern matches times every 10 minutes
digestPattern, digestPattern,
// only deliver 10 latest messages to callback // only deliver 10 latest messages to callback
......
...@@ -13,10 +13,9 @@ You can roll up multiple message ids into this same schedule ...@@ -13,10 +13,9 @@ You can roll up multiple message ids into this same schedule
// Maybe our default will be a line with the message id, followed by a count of those rolled up // Maybe our default will be a line with the message id, followed by a count of those rolled up
match is a regex against a ISO-8601 string pattern is a regex against a ISO-8601 string
secondsGranularity - instead of comparing pattern every minute, true sets interval to every second
*/ */
var Digest = function(secondsGranularity, pattern, cacheSize, deliveryCallback) { var Digest = function(pattern, cacheSize, deliveryCallback) {
var self = this; var self = this;
this.pattern = pattern; this.pattern = pattern;
...@@ -49,28 +48,12 @@ var Digest = function(secondsGranularity, pattern, cacheSize, deliveryCallback) ...@@ -49,28 +48,12 @@ var Digest = function(secondsGranularity, pattern, cacheSize, deliveryCallback)
self.cache = {}; self.cache = {};
} }
}; };
// Schedule delivery // Compare date pattern every second
if (secondsGranularity) { this.intervalHandle = setInterval(
this.intervalHandle = setInterval( _intervalCallback,
_intervalCallback, // Every second
// Every second 1000
1000 );
);
} else {
var now = new Date();
var diff = 60 - (now.getSeconds() % 60);
setTimeout(
function() {
_intervalCallback();
this.intervalHandle = setInterval(
_intervalCallback,
// Every minute
60 * 1000
);
},
diff * 1000
);
}
}; };
......
...@@ -18,7 +18,7 @@ tap.test('digest.second', function(test) { ...@@ -18,7 +18,7 @@ tap.test('digest.second', function(test) {
digest.stop(); digest.stop();
test.end(); test.end();
}; };
var digest = new Harbinger.Digest(true, null, 10, callback); var digest = new Harbinger.Digest(null, 10, callback);
digest.add(123, {message: 'Test'}); digest.add(123, {message: 'Test'});
digest.add(123, {message: 'Another'}); digest.add(123, {message: 'Another'});
...@@ -51,7 +51,7 @@ tap.test('digest.five-second', function(test) { ...@@ -51,7 +51,7 @@ tap.test('digest.five-second', function(test) {
}; };
// This pattern matches "every 5 seconds" // This pattern matches "every 5 seconds"
var digest = new Harbinger.Digest(true, /(\d0|\d5)\.\d{1,3}Z/, 10, callback); var digest = new Harbinger.Digest(/(\d0|\d5)\.\d{1,3}Z/, 10, callback);
for (var messageId in messageTypes) { for (var messageId in messageTypes) {
var messages = messageTypes[messageId]; var messages = messageTypes[messageId];
...@@ -77,7 +77,7 @@ tap.test('digest.cache-size', function(test) { ...@@ -77,7 +77,7 @@ tap.test('digest.cache-size', function(test) {
digest.stop(); digest.stop();
test.end(); test.end();
}; };
var digest = new Harbinger.Digest(true, null, 10, callback); var digest = new Harbinger.Digest(null, 10, callback);
for (var i = 0; i < 100; i++) { for (var i = 0; i < 100; i++) {
digest.add(123, {message: 'Test ' + i}); digest.add(123, {message: 'Test ' + i});
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment