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;
// ISO-8601 format is: YYYY-MM-DDTHH:mm:ss.sssZ
var digestPattern = /T\d\d:[012345]0:00.\d\d\dZ$/;
var everyTenMinutes = new Harbinger.Digest(
// evaluate every minute
false,
// pattern matches times every 10 minutes
digestPattern,
// only deliver 10 latest messages to callback
......
......@@ -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
match is a regex against a ISO-8601 string
secondsGranularity - instead of comparing pattern every minute, true sets interval to every second
pattern is a regex against a ISO-8601 string
*/
var Digest = function(secondsGranularity, pattern, cacheSize, deliveryCallback) {
var Digest = function(pattern, cacheSize, deliveryCallback) {
var self = this;
this.pattern = pattern;
......@@ -49,28 +48,12 @@ var Digest = function(secondsGranularity, pattern, cacheSize, deliveryCallback)
self.cache = {};
}
};
// Schedule delivery
if (secondsGranularity) {
this.intervalHandle = setInterval(
_intervalCallback,
// Every second
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
);
}
// Compare date pattern every second
this.intervalHandle = setInterval(
_intervalCallback,
// Every second
1000
);
};
......
......@@ -18,7 +18,7 @@ tap.test('digest.second', function(test) {
digest.stop();
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: 'Another'});
......@@ -51,7 +51,7 @@ tap.test('digest.five-second', function(test) {
};
// 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) {
var messages = messageTypes[messageId];
......@@ -77,7 +77,7 @@ tap.test('digest.cache-size', function(test) {
digest.stop();
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++) {
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