Skip to content
Snippets Groups Projects
Unverified Commit 28b955f5 authored by Karishma Chadha's avatar Karishma Chadha Committed by GitHub
Browse files

Merge pull request #3916 from kchadha/cloud-msg-throttle

Cloud Variable Rate Limit
parents 7a89f9f1 1fe39b74
Branches
No related tags found
No related merge requests found
......@@ -73,6 +73,7 @@
"lodash.isequal": "4.5.0",
"lodash.omit": "4.5.0",
"lodash.pick": "4.4.0",
"lodash.throttle": "4.0.1",
"minilog": "3.1.0",
"mkdirp": "^0.5.1",
"postcss-import": "^12.0.0",
......
import log from './log.js';
import throttle from 'lodash.throttle';
class CloudProvider {
......@@ -25,6 +26,10 @@ class CloudProvider {
this.queuedData = [];
this.openConnection();
// Send a message to the cloud server at a rate of no more
// than 10 messages/sec.
this.sendCloudData = throttle(this._sendCloudData, 100);
}
/**
......@@ -149,7 +154,7 @@ class CloudProvider {
* Send a formatted message to the cloud data server.
* @param {string} data The formatted message to send.
*/
sendCloudData (data) {
_sendCloudData (data) {
this.connection.send(`${data}\n`);
log.info(`Sent message to clouddata server: ${data}`);
}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment