-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
skyring, server: sets default behavior to not auto rebalance
The previous behavior would send every server in the cluster into a rebalance every time a server was added or removed from the cluster. This can lead to some undesireable bahavior. Adds a new option `autorebalance` that can be enabled if that behavior is desired. By default a server will rebalance when it leaves the cluster. Additionally, the linux signal SIGUSR2 can be sent to the parent process to trigger a specific node to rebalance Semver: major
- Loading branch information
Eric Satterwhite
committed
Apr 26, 2020
1 parent
3271ad7
commit 51f8490
Showing
18 changed files
with
1,002 additions
and
338 deletions.
There are no files selected for viewing
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
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
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
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
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,61 +1,61 @@ | ||
'use strict'; | ||
'use strict' | ||
|
||
const type_exp = /^\[object (.*)\]$/; | ||
const transports = require('../../../transports'); | ||
const type_exp = /^\[object (.*)\]$/ | ||
const transports = require('../../../transports') | ||
|
||
function typeOf(obj) { | ||
if (obj === null) return 'Null'; | ||
if (obj === undefined) return 'Undefined'; | ||
return type_exp.exec( Object.prototype.toString.call(obj) )[1]; | ||
if (obj === null) return 'Null' | ||
if (obj === undefined) return 'Undefined' | ||
return type_exp.exec(Object.prototype.toString.call(obj))[1] | ||
} | ||
|
||
// 2^32 - 1 | ||
const MAX_TIMEOUT_VALUE = 2147483647; | ||
const MAX_TIMEOUT_VALUE = 2147483647 | ||
|
||
module.exports = function(data = {}, cb) { | ||
if (isNaN(data.timeout) || data.timeout < 1) { | ||
const err = new TypeError('timeout is required and must be a positive number'); | ||
err.statusCode = 400; | ||
return setImmediate(cb, err); | ||
const err = new TypeError('timeout is required and must be a positive number') | ||
err.statusCode = 400 | ||
return setImmediate(cb, err) | ||
} | ||
|
||
if (data.timeout > MAX_TIMEOUT_VALUE) { | ||
const err = new TypeError(`timeout must be less than or equal to 2147483647 milliseconds`); | ||
err.statusCode = 400; | ||
return setImmediate(cb, err); | ||
const err = new TypeError(`timeout must be less than or equal to 2147483647 milliseconds`) | ||
err.statusCode = 400 | ||
return setImmediate(cb, err) | ||
} | ||
|
||
if (data.data) { | ||
const type = typeOf(data.data); | ||
const type = typeOf(data.data) | ||
if (data.data != null) { | ||
if (type !== 'String' && type !== 'Object') { | ||
const err = new TypeError('data is required and must be a string or object'); | ||
err.statusCode = 400; | ||
return setImmediate(cb, err); | ||
const err = new TypeError(`data is required and must be a string or object. Got ${type}`) | ||
err.statusCode = 400 | ||
return setImmediate(cb, err) | ||
} | ||
} | ||
|
||
if (typeOf(data.callback) !== 'Object') { | ||
const err = new TypeError('callback is required and must be an object'); | ||
err.statusCode = 400; | ||
return setImmediate(cb, err); | ||
const err = new TypeError('callback is required and must be an object') | ||
err.statusCode = 400 | ||
return setImmediate(cb, err) | ||
} | ||
|
||
if (typeOf(data.callback.transport) !== 'String') { | ||
const err = new TypeError('callback.transport is required and must be a string'); | ||
err.statusCode = 400; | ||
return setImmediate(cb, err); | ||
const err = new TypeError(`callback.transport is required and must be a string. Got ${type}`) | ||
err.statusCode = 400 | ||
return setImmediate(cb, err) | ||
} | ||
|
||
if (typeOf(data.callback.uri) !== 'String') { | ||
const err = new TypeError('callback.uri is required and must be a string'); | ||
err.statusCode = 400; | ||
return setImmediate(cb, err); | ||
const err = new TypeError(`callback.uri is required and must be a string. Got ${type}`) | ||
err.statusCode = 400 | ||
return setImmediate(cb, err) | ||
} | ||
|
||
if (typeOf(data.callback.method) !== 'String') { | ||
const err = new TypeError('callback.method is required and must be a string'); | ||
err.statusCode = 400; | ||
return setImmediate(cb, err); | ||
const err = new TypeError(`callback.method is required and must be a string. Got ${type}`) | ||
err.statusCode = 400 | ||
return setImmediate(cb, err) | ||
} | ||
setImmediate(cb, null, data); | ||
}; | ||
setImmediate(cb, null, data) | ||
} |
Oops, something went wrong.