g_lua.writeFunction("setConsistentHashingBalancingFactor", [](double factor) {
setLuaSideEffect();
- g_consistentHashBalancingFactor = factor;
+ if (factor >= 0) {
+ g_consistentHashBalancingFactor = factor;
+ }
+ else {
+ errlog("Invalid value passed to setConsistentHashingBalancingFactor()!");
+ g_outputBuffer="Invalid value passed to setConsistentHashingBalancingFactor()!\n";
+ return;
+ }
});
g_lua.writeFunction("setRingBuffersSize", [](size_t capacity, boost::optional<size_t> numberOfShards) {
shared_ptr<DownstreamState> ret = nullptr, first = nullptr;
double targetLoad = std::numeric_limits<double>::max();
- if (g_consistentHashBalancingFactor != 0) {
+ if (g_consistentHashBalancingFactor > 0) {
/* we start with one, representing the query we are currently handling */
double currentLoad = 1;
for (const auto& pair : servers) {