refactor: remove unneeded code (see elasticsearch constructor)

This commit is contained in:
Jovan Krunić
2020-10-23 10:08:34 +02:00
committed by Rainer Killinger
parent 7a9f3eaca4
commit af305aa196

View File

@@ -369,7 +369,7 @@ export class Elasticsearch implements Database {
public async bulkUpdated(bulk: Bulk): Promise<void> { public async bulkUpdated(bulk: Bulk): Promise<void> {
// if our es instance is not ready yet, we cannot serve this request // if our es instance is not ready yet, we cannot serve this request
if (!this.ready) { if (!this.ready) {
throw new Error('Elasticsearch not ready'); throw new Error('No connection to elasticsearch established yet.');
} }
// index name for elasticsearch // index name for elasticsearch
@@ -463,7 +463,7 @@ export class Elasticsearch implements Database {
throw new Error('Monitoring is defined, but MailQueue is undefined. A MailQueue is obligatory for monitoring.'); throw new Error('Monitoring is defined, but MailQueue is undefined. A MailQueue is obligatory for monitoring.');
} }
// read all watches and schedule searches on the client // read all watches and schedule searches on the client
Monitoring.setUp(monitoringConfiguration, this.client, this.mailQueue); await Monitoring.setUp(monitoringConfiguration, this.client, this.mailQueue);
} }
return this.getAliasMap(); return this.getAliasMap();
@@ -548,16 +548,10 @@ export class Elasticsearch implements Database {
throw new Error('Database is undefined. You have to configure the query build'); throw new Error('Database is undefined. You have to configure the query build');
} }
// check if the database version is defined and in the expected format
if (typeof this.config.internal.database.version === 'undefined'
|| typeof this.config.internal.database.version !== 'string') {
throw new Error('Database version is malformed. Check your config file');
}
// create elasticsearch configuration out of data from database configuration // create elasticsearch configuration out of data from database configuration
const esConfig: ElasticsearchConfig = { const esConfig: ElasticsearchConfig = {
name: this.config.internal.database.name as 'elasticsearch', name: this.config.internal.database.name as 'elasticsearch',
version: this.config.internal.database.version, version: this.config.internal.database.version as string,
}; };
if (typeof this.config.internal.database.query !== 'undefined') { if (typeof this.config.internal.database.query !== 'undefined') {