Skip to content

Commit

Permalink
collectors as array in constructor
Browse files Browse the repository at this point in the history
  • Loading branch information
Bamieh committed Nov 25, 2019
1 parent 6cec0a2 commit 4d5e9f7
Showing 1 changed file with 6 additions and 6 deletions.
12 changes: 6 additions & 6 deletions src/plugins/usage_collection/server/collector/collector_set.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}

Expand Down Expand Up @@ -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;
};
}

0 comments on commit 4d5e9f7

Please sign in to comment.