Skip to content

Commit

Permalink
[ftr/kbnServer] prevent caching errors when fetching status (#12848)
Browse files Browse the repository at this point in the history
  • Loading branch information
spalger authored Jul 14, 2017
1 parent 8f34633 commit 10656c2
Showing 1 changed file with 13 additions and 5 deletions.
18 changes: 13 additions & 5 deletions test/common/services/kibana_server/version.js
Original file line number Diff line number Diff line change
@@ -1,12 +1,20 @@
import { once } from 'lodash';

export class KibanaServerVersion {
constructor(kibanaStatus) {
this.kibanaStatus = kibanaStatus;
this._cachedVersionNumber;
}

get = once(async () => {
async get() {
if (this._cachedVersionNumber) {
return this._cachedVersionNumber;
}

const status = await this.kibanaStatus.get();
return status.version.number;
})
if (status && status.version && status.version.number) {
this._cachedVersionNumber = status.version.number;
return this._cachedVersionNumber;
}

throw new Error(`Unable to fetch Kibana Server status, received ${JSON.stringify(status)}`);
}
}

0 comments on commit 10656c2

Please sign in to comment.