Merge pull request #7 from DavidSouther/fluctuating-latency

Currency service injects additional latency on predictable schedule (100ms latency from 8am to 5pm server local time)
This commit is contained in:
David Souther 2019-05-22 11:51:01 +02:00 committed by GitHub
commit e195d90ba4
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -71,7 +71,13 @@ function _loadProto (path) {
*/ */
function _getCurrencyData (callback) { function _getCurrencyData (callback) {
const data = require('./data/currency_conversion.json'); const data = require('./data/currency_conversion.json');
callback(data); // Currency conversion API slows down during peak hours.
let delay = 0;
const hour = new Date().getHours();
if (hour > 8 && hour < 17) {
delay = 100; // add 100ms slowdown
}
setTimeout(() => callback(data), delay);
} }
/** /**