kuzzle 2.60.1-beta.1 → 2.61.0-beta.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.d.ts +2 -0
- package/dist/index.js +2 -0
- package/dist/lib/api/controllers/serverController.js +9 -6
- package/dist/lib/cluster/idCardHandler.d.ts +11 -1
- package/dist/lib/cluster/idCardHandler.js +10 -2
- package/dist/lib/cluster/node.d.ts +14 -0
- package/dist/lib/cluster/node.js +19 -0
- package/dist/lib/core/backend/backendStorage.js +4 -6
- package/dist/lib/core/plugin/pluginContext.js +2 -2
- package/dist/lib/core/storage/clientAdapter.d.ts +13 -10
- package/dist/lib/core/storage/clientAdapter.js +112 -60
- package/dist/lib/core/storage/conformance/capabilityCases.d.ts +3 -0
- package/dist/lib/core/storage/conformance/capabilityCases.js +121 -0
- package/dist/lib/core/storage/conformance/conformanceContext.d.ts +33 -0
- package/dist/lib/core/storage/conformance/conformanceContext.js +97 -0
- package/dist/lib/core/storage/conformance/conformanceEnvironment.d.ts +7 -0
- package/dist/lib/core/storage/conformance/conformanceEnvironment.js +136 -0
- package/dist/lib/core/storage/conformance/coreCases.d.ts +3 -0
- package/dist/lib/core/storage/conformance/coreCases.js +381 -0
- package/dist/lib/core/storage/conformance/storageDriverConformance.d.ts +53 -0
- package/dist/lib/core/storage/conformance/storageDriverConformance.js +89 -0
- package/dist/lib/core/storage/indexCache.d.ts +26 -2
- package/dist/lib/core/storage/indexCache.js +100 -2
- package/dist/lib/core/storage/storageDriverLoader.d.ts +41 -0
- package/dist/lib/core/storage/storageDriverLoader.js +276 -0
- package/dist/lib/core/storage/storageEngine.js +5 -1
- package/dist/lib/core/storage/storageError.d.ts +15 -0
- package/dist/lib/core/storage/storageError.js +36 -0
- package/dist/lib/kerror/codes/1-services.json +35 -0
- package/dist/lib/kerror/codes/8-cluster.json +6 -0
- package/dist/lib/service/storage/7/elasticsearch.d.ts +5 -1
- package/dist/lib/service/storage/builtInDrivers.d.ts +17 -0
- package/dist/lib/service/storage/builtInDrivers.js +61 -0
- package/dist/lib/service/storage/storageService.d.ts +13 -0
- package/dist/lib/service/storage/storageService.js +44 -0
- package/dist/lib/types/config/storageEngine/StorageEngineElasticsearchConfiguration.d.ts +8 -1
- package/dist/lib/types/index.d.ts +1 -0
- package/dist/lib/types/index.js +1 -0
- package/dist/lib/types/storage/StorageDriver.d.ts +306 -0
- package/dist/lib/types/storage/StorageDriver.js +41 -0
- package/dist/package.json +2 -1
- package/package.json +2 -1
- package/dist/lib/service/storage/Elasticsearch.d.ts +0 -16
- package/dist/lib/service/storage/Elasticsearch.js +0 -48
package/dist/index.d.ts
CHANGED
|
@@ -45,4 +45,6 @@ export * from "./lib/core/shared/ObjectRepository";
|
|
|
45
45
|
export * from "./lib/core/shared/store";
|
|
46
46
|
export * from "./lib/core/cache/cacheDbEnum";
|
|
47
47
|
export * from "./lib/core/storage/storeScopeEnum";
|
|
48
|
+
export * from "./lib/core/storage/conformance/storageDriverConformance";
|
|
49
|
+
export * from "./lib/core/storage/storageError";
|
|
48
50
|
export * from "./lib/service/storage/commons/queryTranslator";
|
package/dist/index.js
CHANGED
|
@@ -78,5 +78,7 @@ __exportStar(require("./lib/core/shared/ObjectRepository"), exports);
|
|
|
78
78
|
__exportStar(require("./lib/core/shared/store"), exports);
|
|
79
79
|
__exportStar(require("./lib/core/cache/cacheDbEnum"), exports);
|
|
80
80
|
__exportStar(require("./lib/core/storage/storeScopeEnum"), exports);
|
|
81
|
+
__exportStar(require("./lib/core/storage/conformance/storageDriverConformance"), exports);
|
|
82
|
+
__exportStar(require("./lib/core/storage/storageError"), exports);
|
|
81
83
|
__exportStar(require("./lib/service/storage/commons/queryTranslator"), exports);
|
|
82
84
|
//# sourceMappingURL=index.js.map
|
|
@@ -141,10 +141,13 @@ class ServerController extends baseController_1.NativeController {
|
|
|
141
141
|
*
|
|
142
142
|
* @returns {Promise<Object>}
|
|
143
143
|
*/
|
|
144
|
-
|
|
144
|
+
getConfig() {
|
|
145
145
|
// Secrets are masked before the JSON clone: the clone turns a `Buffer`
|
|
146
146
|
// into `{ type, data }`, which would no longer be masked whole (ADR-0004).
|
|
147
|
-
|
|
147
|
+
const publicConfig = (0, redactSecrets_1.toPublicConfig)(global.kuzzle.config);
|
|
148
|
+
const config = JSON.parse(JSON.stringify(publicConfig)); // NOSONAR: intentional JSON-safe deep clone (strips non-serializable config values); structuredClone would change semantics / can throw
|
|
149
|
+
// A Promise, not a value: the funnel rejects an action that returns none.
|
|
150
|
+
return Promise.resolve(config);
|
|
148
151
|
}
|
|
149
152
|
/**
|
|
150
153
|
* Returns the Kuzzle capabilities
|
|
@@ -193,8 +196,8 @@ class ServerController extends baseController_1.NativeController {
|
|
|
193
196
|
/**
|
|
194
197
|
* @returns {Promise<Object>}
|
|
195
198
|
*/
|
|
196
|
-
|
|
197
|
-
return { now: Date.now() };
|
|
199
|
+
now() {
|
|
200
|
+
return Promise.resolve({ now: Date.now() });
|
|
198
201
|
}
|
|
199
202
|
/**
|
|
200
203
|
* @returns {Promise<Object>}
|
|
@@ -293,10 +296,10 @@ class ServerController extends baseController_1.NativeController {
|
|
|
293
296
|
serverInfo: response,
|
|
294
297
|
};
|
|
295
298
|
}
|
|
296
|
-
|
|
299
|
+
publicApi() {
|
|
297
300
|
const kuzzleApi = this._buildApiDefinition(global.kuzzle.funnel.controllers, global.kuzzle.config.http.routes);
|
|
298
301
|
const pluginsApi = this._buildApiDefinition(global.kuzzle.pluginsManager.controllers, global.kuzzle.pluginsManager.routes);
|
|
299
|
-
return { ...kuzzleApi, ...pluginsApi };
|
|
302
|
+
return Promise.resolve({ ...kuzzleApi, ...pluginsApi });
|
|
300
303
|
}
|
|
301
304
|
async openapi(request) {
|
|
302
305
|
const format = request.getString("format", "json");
|
|
@@ -5,6 +5,11 @@ export type SerializedIdCard = {
|
|
|
5
5
|
ip: string;
|
|
6
6
|
birthdate: number;
|
|
7
7
|
topology: string[];
|
|
8
|
+
/**
|
|
9
|
+
* `<package name>@<version>` of the node's external storage driver. Not
|
|
10
|
+
* set with a built-in driver, as on the nodes that predate the drivers.
|
|
11
|
+
*/
|
|
12
|
+
storageDriver?: string;
|
|
8
13
|
};
|
|
9
14
|
export declare class IdCard {
|
|
10
15
|
/**
|
|
@@ -31,7 +36,12 @@ export declare class IdCard {
|
|
|
31
36
|
* Set<node-id>
|
|
32
37
|
*/
|
|
33
38
|
topology: Set<string>;
|
|
34
|
-
|
|
39
|
+
/**
|
|
40
|
+
* The node's external storage driver, `<package name>@<version>`;
|
|
41
|
+
* `undefined` with a built-in one
|
|
42
|
+
*/
|
|
43
|
+
readonly storageDriver?: string;
|
|
44
|
+
constructor({ id, ip, birthdate, topology, storageDriver, }: SerializedIdCard);
|
|
35
45
|
serialize(): SerializedIdCard;
|
|
36
46
|
static unserialize(serialized: SerializedIdCard): IdCard;
|
|
37
47
|
}
|
|
@@ -32,19 +32,26 @@ require("../types");
|
|
|
32
32
|
const REDIS_PREFIX = "{cluster/node}/";
|
|
33
33
|
const REDIS_ID_CARDS_INDEX = REDIS_PREFIX + "id-cards-index";
|
|
34
34
|
class IdCard {
|
|
35
|
-
constructor({ id, ip, birthdate, topology }) {
|
|
35
|
+
constructor({ id, ip, birthdate, topology, storageDriver, }) {
|
|
36
36
|
this.id = id;
|
|
37
37
|
this.ip = ip;
|
|
38
38
|
this.birthdate = birthdate;
|
|
39
39
|
this.topology = new Set(topology);
|
|
40
|
+
this.storageDriver = storageDriver;
|
|
40
41
|
}
|
|
41
42
|
serialize() {
|
|
42
|
-
|
|
43
|
+
const serialized = {
|
|
43
44
|
birthdate: this.birthdate,
|
|
44
45
|
id: this.id,
|
|
45
46
|
ip: this.ip,
|
|
46
47
|
topology: Array.from(this.topology),
|
|
47
48
|
};
|
|
49
|
+
// Left out with a built-in driver: the card stays what it was before the
|
|
50
|
+
// drivers
|
|
51
|
+
if (this.storageDriver !== undefined) {
|
|
52
|
+
serialized.storageDriver = this.storageDriver;
|
|
53
|
+
}
|
|
54
|
+
return serialized;
|
|
48
55
|
}
|
|
49
56
|
static unserialize(serialized) {
|
|
50
57
|
return new IdCard(serialized);
|
|
@@ -128,6 +135,7 @@ class ClusterIdCardHandler {
|
|
|
128
135
|
birthdate: Date.now(),
|
|
129
136
|
id: this.nodeId,
|
|
130
137
|
ip: this.ip,
|
|
138
|
+
storageDriver: this.node.storageDriver,
|
|
131
139
|
topology: [],
|
|
132
140
|
});
|
|
133
141
|
reserved = await this.save({ creation: true });
|
|
@@ -71,6 +71,12 @@ declare class ClusterNode {
|
|
|
71
71
|
* removed, to give more insights to cluster statuses
|
|
72
72
|
*/
|
|
73
73
|
activity: NodeActivity[];
|
|
74
|
+
/**
|
|
75
|
+
* `<package name>@<version>` of this node's external storage driver,
|
|
76
|
+
* `undefined` with a built-in one: every node of a cluster must run the
|
|
77
|
+
* same
|
|
78
|
+
*/
|
|
79
|
+
readonly storageDriver?: string;
|
|
74
80
|
constructor();
|
|
75
81
|
get syncAddress(): string;
|
|
76
82
|
init(): Promise<string>;
|
|
@@ -168,6 +174,14 @@ declare class ClusterNode {
|
|
|
168
174
|
* @throws {cluster.join.duplicate_ip} if it is
|
|
169
175
|
*/
|
|
170
176
|
private discoverNodes;
|
|
177
|
+
/**
|
|
178
|
+
* The built-in drivers are not compared, so that an Elasticsearch 7 / 8
|
|
179
|
+
* cluster joins exactly as it did before the drivers.
|
|
180
|
+
*
|
|
181
|
+
* @throws {cluster.join.storage_driver_mismatch} if a node runs another
|
|
182
|
+
* storage driver than this one
|
|
183
|
+
*/
|
|
184
|
+
private assertSameStorageDriver;
|
|
171
185
|
/**
|
|
172
186
|
* Discovers other active nodes from the cluster and, if other nodes exist,
|
|
173
187
|
* starts a handshake procedure to sync this node and to make it able to
|
package/dist/lib/cluster/node.js
CHANGED
|
@@ -70,6 +70,7 @@ const eventemitter3_1 = __importDefault(require("eventemitter3"));
|
|
|
70
70
|
const intersection_1 = __importDefault(require("lodash/intersection"));
|
|
71
71
|
const xor_1 = __importDefault(require("lodash/xor"));
|
|
72
72
|
const long_1 = __importDefault(require("long"));
|
|
73
|
+
const storageDriverLoader_1 = require("../core/storage/storageDriverLoader");
|
|
73
74
|
const kerror = __importStar(require("../kerror"));
|
|
74
75
|
const kuzzleError_1 = require("../kerror/errors/kuzzleError");
|
|
75
76
|
const kuzzleStateEnum_1 = __importDefault(require("../kuzzle/kuzzleStateEnum"));
|
|
@@ -228,6 +229,9 @@ class ClusterNode {
|
|
|
228
229
|
constructor() {
|
|
229
230
|
this._nodeId = null;
|
|
230
231
|
this.config = global.kuzzle.config.cluster;
|
|
232
|
+
this.storageDriver =
|
|
233
|
+
(0, storageDriverLoader_1.selectStorageDriver)(global.kuzzle.config.services.storageEngine)
|
|
234
|
+
.identity ?? undefined;
|
|
231
235
|
this.logger = global.kuzzle.log.child("cluster:node");
|
|
232
236
|
this.heartbeatDelay = this.config.heartbeat;
|
|
233
237
|
const family = this.config.ipv6 ? "IPv6" : "IPv4";
|
|
@@ -623,6 +627,20 @@ class ClusterNode {
|
|
|
623
627
|
}
|
|
624
628
|
return remaining;
|
|
625
629
|
}
|
|
630
|
+
/**
|
|
631
|
+
* The built-in drivers are not compared, so that an Elasticsearch 7 / 8
|
|
632
|
+
* cluster joins exactly as it did before the drivers.
|
|
633
|
+
*
|
|
634
|
+
* @throws {cluster.join.storage_driver_mismatch} if a node runs another
|
|
635
|
+
* storage driver than this one
|
|
636
|
+
*/
|
|
637
|
+
assertSameStorageDriver(nodes) {
|
|
638
|
+
const other = nodes.find((node) => node.storageDriver !== this.storageDriver);
|
|
639
|
+
if (other) {
|
|
640
|
+
const describe = (driver) => driver ?? "a built-in Elasticsearch driver";
|
|
641
|
+
throw joinError.get("storage_driver_mismatch", describe(this.storageDriver), other.id, describe(other.storageDriver));
|
|
642
|
+
}
|
|
643
|
+
}
|
|
626
644
|
/**
|
|
627
645
|
* Discovers other active nodes from the cluster and, if other nodes exist,
|
|
628
646
|
* starts a handshake procedure to sync this node and to make it able to
|
|
@@ -666,6 +684,7 @@ class ClusterNode {
|
|
|
666
684
|
do {
|
|
667
685
|
nodes = await this.discoverNodes();
|
|
668
686
|
debug("[CLUSTER] %s remote nodes discovered", nodes.length);
|
|
687
|
+
this.assertSameStorageDriver(nodes);
|
|
669
688
|
// No other nodes detected = no handshake required
|
|
670
689
|
if (nodes.length === 0) {
|
|
671
690
|
this.trackActivity(this.nodeId, this.ip, nodeActivityEnum.ADDED);
|
|
@@ -21,7 +21,7 @@
|
|
|
21
21
|
*/
|
|
22
22
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
23
23
|
exports.BackendStorage = void 0;
|
|
24
|
-
const
|
|
24
|
+
const storageDriverLoader_1 = require("../storage/storageDriverLoader");
|
|
25
25
|
const index_1 = require("./index");
|
|
26
26
|
class BackendStorage extends index_1.ApplicationManager {
|
|
27
27
|
constructor() {
|
|
@@ -39,10 +39,10 @@ class BackendStorage extends index_1.ApplicationManager {
|
|
|
39
39
|
get StorageClient() {
|
|
40
40
|
const kuzzle = this._kuzzle;
|
|
41
41
|
this._Client ?? (this._Client = function ESClient(clientConfig = {}) {
|
|
42
|
-
return
|
|
42
|
+
return (0, storageDriverLoader_1.createNativeStorageClient)(kuzzle.config.services.storageEngine, {
|
|
43
43
|
...kuzzle.config.services.storageEngine.client,
|
|
44
44
|
...clientConfig,
|
|
45
|
-
}
|
|
45
|
+
});
|
|
46
46
|
});
|
|
47
47
|
return this._Client;
|
|
48
48
|
}
|
|
@@ -53,9 +53,7 @@ class BackendStorage extends index_1.ApplicationManager {
|
|
|
53
53
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any -- kept for v2 compatibility, see docs/v3-breaking-changes.md
|
|
54
54
|
get storageClient() {
|
|
55
55
|
const kuzzle = this._kuzzle;
|
|
56
|
-
|
|
57
|
-
this._client = Elasticsearch_1.Elasticsearch.buildClient(kuzzle.config.services.storageEngine.client, kuzzle.config.services.storageEngine.majorVersion);
|
|
58
|
-
}
|
|
56
|
+
this._client ?? (this._client = (0, storageDriverLoader_1.createNativeStorageClient)(kuzzle.config.services.storageEngine, kuzzle.config.services.storageEngine.client));
|
|
59
57
|
return this._client;
|
|
60
58
|
}
|
|
61
59
|
}
|
|
@@ -64,7 +64,7 @@ const request_1 = require("../../api/request");
|
|
|
64
64
|
const baseType_1 = __importDefault(require("../validation/baseType"));
|
|
65
65
|
const kerror = __importStar(require("../../kerror"));
|
|
66
66
|
const errors_1 = require("../../kerror/errors");
|
|
67
|
-
const
|
|
67
|
+
const storageDriverLoader_1 = require("../storage/storageDriverLoader");
|
|
68
68
|
const distributedLock_1 = require("../../util/distributedLock");
|
|
69
69
|
const mutex_1 = require("../../util/mutex");
|
|
70
70
|
const promback_1 = __importDefault(require("../../util/promback"));
|
|
@@ -127,7 +127,7 @@ class PluginContext {
|
|
|
127
127
|
};
|
|
128
128
|
}
|
|
129
129
|
function PluginContextESClient() {
|
|
130
|
-
return
|
|
130
|
+
return (0, storageDriverLoader_1.createNativeStorageClient)(global.kuzzle.config.services.storageEngine, global.kuzzle.config.services.storageEngine.client);
|
|
131
131
|
}
|
|
132
132
|
this.constructors = {
|
|
133
133
|
BaseValidationType: baseType_1.default,
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import type { JSONObject } from "../../types/JSONObject";
|
|
2
|
-
import {
|
|
2
|
+
import { StorageService } from "../../service/storage/storageService";
|
|
3
|
+
import { type StorageCapability, type StorageDriver } from "../../types/storage/StorageDriver";
|
|
3
4
|
import { IndexCache, type CollectionLock } from "./indexCache";
|
|
4
5
|
import type { storeScopeEnum } from "./storeScopeEnum";
|
|
5
6
|
import "../../types/Global";
|
|
@@ -21,12 +22,11 @@ type ImportPayload = Record<string, Record<string, JSONObject[]>>;
|
|
|
21
22
|
* and to maintain the index/collection cache.
|
|
22
23
|
*/
|
|
23
24
|
declare class ClientAdapter {
|
|
24
|
-
|
|
25
|
-
/**
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
client: Elasticsearch["client"];
|
|
25
|
+
service: StorageService;
|
|
26
|
+
/** This scope's storage driver instance */
|
|
27
|
+
driver: StorageDriver;
|
|
28
|
+
/** The capability groups the driver declares */
|
|
29
|
+
capabilities: ReadonlySet<StorageCapability>;
|
|
30
30
|
scope: storeScopeEnum;
|
|
31
31
|
cache: IndexCache;
|
|
32
32
|
constructor(scope: storeScopeEnum);
|
|
@@ -42,9 +42,12 @@ declare class ClientAdapter {
|
|
|
42
42
|
*/
|
|
43
43
|
populateCache(): Promise<void>;
|
|
44
44
|
/**
|
|
45
|
-
*
|
|
46
|
-
* then reloads the collection write locks. Unlike `populateCache`,
|
|
47
|
-
* writes to storage.
|
|
45
|
+
* Replaces the index cache with the indexes and collections found in
|
|
46
|
+
* storage, then reloads the collection write locks. Unlike `populateCache`,
|
|
47
|
+
* it never writes to storage.
|
|
48
|
+
*
|
|
49
|
+
* Replaced, not merged: an index or a collection a peer deleted before this
|
|
50
|
+
* node joined the cluster must go too (kuzzle#3040).
|
|
48
51
|
*/
|
|
49
52
|
reloadCache(): Promise<void>;
|
|
50
53
|
/**
|