Skip to content

Commit

Permalink
feat(elasticsearch8): tests unit are now okay
Browse files Browse the repository at this point in the history
  • Loading branch information
rolljee committed Feb 26, 2024
1 parent 56d1b53 commit 1f4d1e8
Show file tree
Hide file tree
Showing 22 changed files with 7,528 additions and 941 deletions.
4 changes: 2 additions & 2 deletions .eslintrc.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
"plugin:kuzzle/node"
],
"rules": {
"sort-keys": "warn",
"kuzzle/array-foreach": "warn"
"sort-keys": "off",
"kuzzle/array-foreach": "off"
}
}
24 changes: 15 additions & 9 deletions lib/core/backend/backendStorage.ts
Original file line number Diff line number Diff line change
Expand Up @@ -34,9 +34,17 @@ export class BackendStorage extends ApplicationManager {
* @param clientConfig Overload configuration for the underlaying storage client
*/
get StorageClient(): new (clientConfig?: any) => any {
const kuzzle = this._kuzzle;

if (!this._Client) {
this._Client = function ESClient(clientConfig: JSONObject = {}) {
return this.getElasticsearchClient(clientConfig);
return Elasticsearch.buildClient(
{
...kuzzle.config.services.storageEngine.client,
...clientConfig,
},
kuzzle.config.services.storageEngine.majorVersion,
);
} as unknown as new (clientConfig?: any) => any;
}

Expand All @@ -48,17 +56,15 @@ export class BackendStorage extends ApplicationManager {
* (Currently Elasticsearch)
*/
get storageClient(): any {
const kuzzle = this._kuzzle;

if (!this._client) {
this._client = this.getElasticsearchClient();
this._client = Elasticsearch.buildClient(
kuzzle.config.services.storageEngine.client,
kuzzle.config.services.storageEngine.majorVersion,
);
}

return this._client;
}

getElasticsearchClient(clientConfig?: JSONObject): any {
return Elasticsearch.buildClient(
{ ...this._kuzzle.config.services.storageEngine.client, ...clientConfig },
this._kuzzle.config.services.storageEngine.majorVersion,
);
}
}
1 change: 1 addition & 0 deletions lib/core/storage/clientAdapter.js
Original file line number Diff line number Diff line change
Expand Up @@ -203,6 +203,7 @@ class ClientAdapter {
* @return {Promise}
* @throws
*/

global.kuzzle.onAsk(
`core:storage:${this.scope}:collection:create`,
(index, collection, opts, creationOptions) =>
Expand Down
7 changes: 3 additions & 4 deletions lib/core/storage/storageEngine.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,6 @@

"use strict";

const Bluebird = require("bluebird");

const kerror = require("../../kerror").wrap("services", "storage");
const ClientAdapter = require("./clientAdapter");
const scopeEnum = require("./storeScopeEnum");
Expand All @@ -42,11 +40,12 @@ class StorageEngine {
* @returns {Promise}
*/
async init() {
await Bluebird.all([this.public.init(), this.private.init()]);
await Promise.all([this.public.init(), this.private.init()]);

const privateIndexes = this.private.cache.listIndexes();
const publicIndexes = this.public.cache.listIndexes();

for (const publicIndex of this.public.cache.listIndexes()) {
for (const publicIndex of publicIndexes) {
if (privateIndexes.includes(publicIndex)) {
throw kerror.get("index_already_exists", "public", publicIndex);
}
Expand Down
Loading

0 comments on commit 1f4d1e8

Please sign in to comment.