Support time discretization in scripts
This can be used to ensure parameter refresh times are aligned (as opposed to using Date.now() - X). It also allows for possible future optimizations by exploiting the fact that the value of Date.now(X) remains static for a given amount of time. The variance value can be used to shift the discretization threshold points based on the hash of the device ID for load distribution. The djb2 hashing algorithm has been replaced with MD5 for better distribution.
This commit is contained in:
1 parent
ed873cdd4a
commit
6a9c62b639
6 files changed
+121
-47
No files matched your search
+2
-7
@@ -21,12 +21,11 @@
|
||||
const vm = require("vm");
|
||||
const crypto = require("crypto");
|
||||
|
||||
const later = require("later");
|
||||
|
||||
const db = require("./db");
|
||||
const cache = require("./cache");
|
||||
const query = require("./query");
|
||||
const logger = require("./logger");
|
||||
const scheduling = require("./scheduling");
|
||||
|
||||
const REFRESH = 3000;
|
||||
|
||||
@@ -125,11 +124,7 @@ function refresh(callback) {
|
||||
|
||||
try {
|
||||
schedule.duration = +(parts.shift()) * 1000;
|
||||
if (parts.length === 5) {
|
||||
parts.unshift("0");
|
||||
// TODO later.js doesn't throw erorr if expression is invalid!
|
||||
schedule.schedule = later.schedule(later.parse.cron(parts.join(" "), true));
|
||||
}
|
||||
schedule.schedule = scheduling.parseCron(parts.join(" "));
|
||||
}
|
||||
catch (err) {
|
||||
logger.warn({
|
||||
|
||||
Reference in new issue
Block a user