Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

clear all open intervals if not needed #16

Merged
merged 1 commit into from Sep 12, 2017
Merged
Changes from all commits
Commits
File filter...
Filter file types
Jump to…
Jump to file
Failed to load files.

Always

Just for now

@@ -206,11 +206,12 @@ common.loggly = function () {
if (timerFunction === null) {
timerFunction = setInterval(function () {
sendBulkLogs();
if (timerFunction && !arrMsg.length) {
clearInterval(timerFunction)
timerFunction = null;
}
},5000);
} else if (timerFunction && !arrMsg.length) {
clearInterval(timerFunction);
timerFunction = null;
}
}
arrMsg.push(requestBody);
if (arrMsg.length === arrSize) {
sendBulkLogs();

This comment has been minimized.

@Shwetajain148

Shwetajain148 Aug 30, 2017
Author

At line #217, sendBulkLogs() function is called inside the if (arrMsg.length === arrSize) condition which basically checks if the arrMsg(an array in which logs get pushed) array's length is equal to arrSize which is 100 then send the all logs instantly without waiting.
And at line #208, sendBulkLogs() function is called inside the setInterval function to keep calling the same function in every 5 seconds.
This is the behaviour of the library since the bulk mode was implemented.

@@ -226,11 +227,12 @@ common.loggly = function () {
if (timerFunctionForBufferedLogs === null) {
timerFunctionForBufferedLogs = setInterval(function () {
if (arrBufferedMsg.length) sendBufferdLogstoLoggly();
if (timerFunctionForBufferedLogs && !arrBufferedMsg.length) {
clearInterval(timerFunctionForBufferedLogs);
timerFunctionForBufferedLogs = null;
}
}, bufferOptions.retriesInMilliSeconds);
} else if (timerFunctionForBufferedLogs && !arrBufferedMsg.length) {
clearInterval(timerFunctionForBufferedLogs);
timerFunctionForBufferedLogs = null;
}
}


function sendBufferdLogstoLoggly() {
ProTip! Use n and p to navigate between commits in a pull request.
You can’t perform that action at this time.