Skip to content

Commit

Permalink
Cache migrator.getActiveMappings to improve createRepository
Browse files Browse the repository at this point in the history
  • Loading branch information
rudolf committed Jun 4, 2020
1 parent c5e446a commit ef30e36
Showing 1 changed file with 5 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,7 @@ export class KibanaMigrator {
private readonly status$ = new BehaviorSubject<KibanaMigratorStatus>({
status: 'waiting',
});
private readonly activeMappings: IndexMapping;

/**
* Creates an instance of KibanaMigrator.
Expand All @@ -100,6 +101,9 @@ export class KibanaMigrator {
validateDoc: docValidator(savedObjectValidations || {}),
log: this.log,
});
// Building the active mappings (and associated md5sums) is an expensive
// operation so we cache the result
this.activeMappings = buildActiveMappings(this.mappingProperties);
}

/**
Expand Down Expand Up @@ -172,7 +176,7 @@ export class KibanaMigrator {
*
*/
public getActiveMappings(): IndexMapping {
return buildActiveMappings(this.mappingProperties);
return this.activeMappings;
}

/**
Expand Down

0 comments on commit ef30e36

Please sign in to comment.