diff --git a/src/service-broker.js b/src/service-broker.js index 720033a8d..aac4410fb 100644 --- a/src/service-broker.js +++ b/src/service-broker.js @@ -93,7 +93,8 @@ const defaultOptions = { maxQueueSize: 50 * 1000, // 50k ~ 400MB, maxChunkSize: 256 * 1024, // 256KB disableReconnect: false, - disableVersionCheck: false + disableVersionCheck: false, + serviceChangedDebounceTime: 1000 }, uidGenerator: null, @@ -305,9 +306,14 @@ class ServiceBroker { this.call = this.callWithoutBalancer; } - // Create debounced localServiceChanged - const origLocalServiceChanged = this.localServiceChanged; - this.localServiceChanged = _.debounce(() => origLocalServiceChanged.call(this), 1000); + if (this.options.transit.serviceChangedDebounceTime > 0) { + // Create debounced localServiceChanged + const origLocalServiceChanged = this.localServiceChanged; + this.localServiceChanged = _.debounce( + () => origLocalServiceChanged.call(this), + this.options.transit.serviceChangedDebounceTime + ); + } this.registry.init(this); diff --git a/test/unit/service-broker.spec.js b/test/unit/service-broker.spec.js index 1fad1ea50..cfe2fc28b 100644 --- a/test/unit/service-broker.spec.js +++ b/test/unit/service-broker.spec.js @@ -266,7 +266,8 @@ describe("Test ServiceBroker constructor", () => { disableReconnect: false, maxQueueSize: 50 * 1000, maxChunkSize: 262144, - disableVersionCheck: false + disableVersionCheck: false, + serviceChangedDebounceTime: 1000 }, uidGenerator: null,