From 4d5e9f730fd8febf00387e074bb54118f9b7925a Mon Sep 17 00:00:00 2001 From: Ahmad Bamieh Date: Mon, 25 Nov 2019 23:43:45 +0200 Subject: [PATCH] collectors as array in constructor --- .../server/collector/collector_set.ts | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/src/plugins/usage_collection/server/collector/collector_set.ts b/src/plugins/usage_collection/server/collector/collector_set.ts index e33146faae222..a87accc47535e 100644 --- a/src/plugins/usage_collection/server/collector/collector_set.ts +++ b/src/plugins/usage_collection/server/collector/collector_set.ts @@ -28,14 +28,17 @@ import { UsageCollector } from './usage_collector'; interface CollectorSetConfig { logger: Logger; maximumWaitTimeForAllCollectorsInS: number; + collectors?: Collector[]; } + export class CollectorSet { private _waitingForAllCollectorsTimestamp?: number; private logger: Logger; private readonly maximumWaitTimeForAllCollectorsInS: number; private collectors: Collector[] = []; - constructor({ logger, maximumWaitTimeForAllCollectorsInS }: CollectorSetConfig) { + constructor({ logger, maximumWaitTimeForAllCollectorsInS, collectors = [] }: CollectorSetConfig) { this.logger = logger; + this.collectors = collectors; this.maximumWaitTimeForAllCollectorsInS = maximumWaitTimeForAllCollectorsInS || 60; } @@ -197,13 +200,10 @@ export class CollectorSet { }; private makeCollectorSetFromArray = (collectors: Collector[]) => { - const collectorSet = new CollectorSet({ + return new CollectorSet({ logger: this.logger, maximumWaitTimeForAllCollectorsInS: this.maximumWaitTimeForAllCollectorsInS, + collectors, }); - collectors.forEach(collector => { - collectorSet.registerCollector(collector); - }); - return collectorSet; }; }