Skip to content
This repository was archived by the owner on Feb 18, 2021. It is now read-only.

Commit 614a94e

Browse files
authored
Thread remote config for default rate limit (#311)
1 parent bfdc9fb commit 614a94e

File tree

2 files changed

+20
-0
lines changed

2 files changed

+20
-0
lines changed

clients/index.js

+9
Original file line numberDiff line numberDiff line change
@@ -456,6 +456,7 @@ function onRemoteConfigUpdate(changedKeys, forceUpdate) {
456456
self.updateCircuitShorts(hasChanged, forceUpdate);
457457
self.updateCircuitCodeNames(hasChanged, forceUpdate);
458458
self.updateRateLimitingEnabled(hasChanged, forceUpdate);
459+
self.updateDefaultServiceRpsLimit(hasChanged, forceUpdate);
459460
self.updateTotalRpsLimit(hasChanged, forceUpdate);
460461
self.updateExemptServices(hasChanged, forceUpdate);
461462
self.updateRpsLimitForServiceName(hasChanged, forceUpdate);
@@ -636,6 +637,14 @@ ApplicationClients.prototype.updatePartialAffinityEnabled = function updateParti
636637
}
637638
};
638639

640+
ApplicationClients.prototype.updateDefaultServiceRpsLimit = function updateDefaultServiceRpsLimit(hasChanged, forceUpdate) {
641+
var self = this;
642+
if (forceUpdate || hasChanged['ratelimiting.defaultServiceRpsLimit']) {
643+
var limit = self.remoteConfig.get('ratelimiting.defaultServiceRpsLimit', 0);
644+
self.serviceProxy.rateLimiter.updateDefaultServiceRpsLimit(limit);
645+
}
646+
};
647+
639648
ApplicationClients.prototype.updateTotalRpsLimit = function updateTotalRpsLimit(hasChanged, forceUpdate) {
640649
var self = this;
641650
if (forceUpdate || hasChanged['rateLimiting.totalRpsLimit']) {

rate_limiter.js

+11
Original file line numberDiff line numberDiff line change
@@ -310,6 +310,17 @@ function updateServiceLimit(serviceName, limit) {
310310
}
311311
};
312312

313+
RateLimiter.prototype.updateDefaultServiceRpsLimit =
314+
function updateDefaultServiceRpsLimit(limit) {
315+
var self = this;
316+
317+
if (limit === 0) {
318+
self.defaultServiceRpsLimit = DEFAULT_SERVICE_RPS_LIMIT;
319+
} else {
320+
self.defaultServiceRpsLimit = limit;
321+
}
322+
};
323+
313324
RateLimiter.prototype.updateTotalLimit =
314325
function updateTotalLimit(limit) {
315326
var self = this;

0 commit comments

Comments
 (0)