Created
May 11, 2018 00:15
-
-
Save syrnick/cc912ee9314389af4bb9678da7f4e743 to your computer and use it in GitHub Desktop.
Test timers lambda
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var lastRun = new Date(); | |
var numFailed = 0; | |
var numUpdatedTime = 0; | |
var numChecked = 0; | |
var numFatalFailures = 0; | |
setInterval(() => { | |
numUpdatedTime++; | |
console.log('---------- Update time', new Date().toJSON()); | |
lastRun = new Date(); | |
}, 5000); | |
setInterval(() => { | |
numChecked++; | |
if (new Date() - lastRun > 5000) { | |
console.log(' check failed', new Date().toJSON()); | |
numFailed ++; | |
} else { | |
console.log(' check passed', new Date().toJSON()); | |
numFailed = 0; | |
} | |
if (numFailed >= 5) { | |
numFatalFailures++; | |
} | |
}, 200); | |
exports.handler = async (event) => { | |
const response = { | |
numChecked, | |
numUpdatedTime, | |
numFailed, | |
numFatalFailures, | |
}; | |
return JSON.stringify(response); | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment