process-custodian
Advanced tools
Comparing version 0.5.2 to 0.5.3
@@ -452,14 +452,10 @@ 'use strict'; | ||
function _stop() { | ||
var _this2 = this; | ||
process.nextTick(function () { | ||
if (_this2._timeout !== null) { | ||
clearTimeout(_this2._timeout); | ||
_this2._timeout = null; | ||
} | ||
}); | ||
if (this._timeout !== null) { | ||
clearTimeout(this._timeout); | ||
this._timeout = null; | ||
} | ||
} | ||
function runActivityQueue(tickTimeInSeconds, marginTimeForRenew) { | ||
var _this3 = this; | ||
var _this2 = this; | ||
@@ -479,8 +475,8 @@ var isInit = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : false; | ||
case 0: | ||
wasMaster = _this3._isMaster; | ||
lag = Math.max(0, Date.now() - _this3._expectedFiredTime); | ||
wasMaster = _this2._isMaster; | ||
lag = Math.max(0, Date.now() - _this2._expectedFiredTime); | ||
// @see https://en.wikipedia.org/wiki/Exponential_smoothing | ||
// we weigh the current value against the previous value 3:1 to smooth bounds. | ||
_this3._currentLag = _this3._smoothingFactor * lag + (1 - _this3._smoothingFactor) * _this3._currentLag; | ||
_this2._currentLag = _this2._smoothingFactor * lag + (1 - _this2._smoothingFactor) * _this2._currentLag; | ||
_context6.prev = 3; | ||
@@ -494,6 +490,6 @@ | ||
_context6.next = 7; | ||
return renewingMasterReservation.call(_this3, tickTimeInSeconds, marginTimeForRenew); | ||
return renewingMasterReservation.call(_this2, tickTimeInSeconds, marginTimeForRenew); | ||
case 7: | ||
_this3._isMaster = _context6.sent; | ||
_this2._isMaster = _context6.sent; | ||
_context6.next = 14; | ||
@@ -503,3 +499,3 @@ break; | ||
case 10: | ||
if (_this3.isOverloaded()) { | ||
if (_this2.isOverloaded()) { | ||
_context6.next = 14; | ||
@@ -510,10 +506,10 @@ break; | ||
_context6.next = 13; | ||
return tryBeMaster.call(_this3, tickTimeInSeconds, marginTimeForRenew, isInit); | ||
return tryBeMaster.call(_this2, tickTimeInSeconds, marginTimeForRenew, isInit); | ||
case 13: | ||
_this3._isMaster = _context6.sent; | ||
_this2._isMaster = _context6.sent; | ||
case 14: | ||
_context6.next = 16; | ||
return oneHeartbeat.call(_this3, tickTimeInSeconds); | ||
return oneHeartbeat.call(_this2, tickTimeInSeconds); | ||
@@ -533,10 +529,10 @@ case 16: | ||
_this3._expectedFiredTime = Date.now() + tickTimeInSeconds * 1000; | ||
runActivityQueue.call(_this3, tickTimeInSeconds, marginTimeForRenew); | ||
_this3._emitter.emit(_constants.EVENTS.TICK); | ||
if (!wasMaster && _this3._isMaster) { | ||
_this3._emitter.emit(_constants.EVENTS.I_AM_MASTER); | ||
_this2._expectedFiredTime = Date.now() + tickTimeInSeconds * 1000; | ||
runActivityQueue.call(_this2, tickTimeInSeconds, marginTimeForRenew); | ||
_this2._emitter.emit(_constants.EVENTS.TICK); | ||
if (!wasMaster && _this2._isMaster) { | ||
_this2._emitter.emit(_constants.EVENTS.I_AM_MASTER); | ||
} | ||
if ((wasMaster || isInit) && !_this3._isMaster) { | ||
_this3._emitter.emit(_constants.EVENTS.I_AM_SLAVE); | ||
if ((wasMaster || isInit) && !_this2._isMaster) { | ||
_this2._emitter.emit(_constants.EVENTS.I_AM_SLAVE); | ||
} | ||
@@ -550,3 +546,3 @@ return _context6.finish(21); | ||
} | ||
}, _callee6, _this3, [[3, 18, 21, 28]]); | ||
}, _callee6, _this2, [[3, 18, 21, 28]]); | ||
})); | ||
@@ -553,0 +549,0 @@ |
{ | ||
"name": "process-custodian", | ||
"version": "0.5.2", | ||
"version": "0.5.3", | ||
"description": "This package helps with organizing of tasks between few instances of same app, It can identify processes and track them activity.", | ||
@@ -5,0 +5,0 @@ "main": "index.js", |
@@ -242,8 +242,6 @@ import {MASTER_KEY, EVENTS} from './constants'; | ||
function _stop () { | ||
process.nextTick(() => { | ||
if (this._timeout !== null) { | ||
clearTimeout(this._timeout); | ||
this._timeout = null; | ||
} | ||
}); | ||
if (this._timeout !== null) { | ||
clearTimeout(this._timeout); | ||
this._timeout = null; | ||
} | ||
} | ||
@@ -250,0 +248,0 @@ |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
46786
1025