kuzzle 2.60.1 → 2.61.0-beta.2
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/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/config/index.js +43 -8
- 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 +9 -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/builtInDrivers.d.ts +6 -0
- package/dist/lib/service/storage/builtInDrivers.js +103 -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/KuzzleConfiguration.d.ts +8 -0
- package/dist/lib/types/config/storageEngine/StorageEngineElasticsearchConfiguration.d.ts +13 -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 +4 -1
- package/package.json +4 -1
- package/dist/lib/service/storage/7/elasticsearch.d.ts +0 -1054
- package/dist/lib/service/storage/7/elasticsearch.js +0 -3063
- package/dist/lib/service/storage/7/esWrapper.d.ts +0 -36
- package/dist/lib/service/storage/7/esWrapper.js +0 -295
- package/dist/lib/service/storage/8/elasticsearch.d.ts +0 -1047
- package/dist/lib/service/storage/8/elasticsearch.js +0 -3096
- package/dist/lib/service/storage/8/esWrapper.d.ts +0 -36
- package/dist/lib/service/storage/8/esWrapper.js +0 -295
- 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
|
|
@@ -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);
|
package/dist/lib/config/index.js
CHANGED
|
@@ -38,7 +38,7 @@ const wrapped = (0, kerror_1.wrap)("core", "configuration");
|
|
|
38
38
|
function loadConfig() {
|
|
39
39
|
let raw;
|
|
40
40
|
try {
|
|
41
|
-
raw = (0, rc_1.default)("kuzzle",
|
|
41
|
+
raw = (0, rc_1.default)("kuzzle", withoutUnsetDefaults(default_config_1.default));
|
|
42
42
|
}
|
|
43
43
|
catch (e) {
|
|
44
44
|
throw wrapped.get("cannot_parse", e instanceof Error ? e.message : (0, node_util_1.inspect)(e));
|
|
@@ -46,9 +46,11 @@ function loadConfig() {
|
|
|
46
46
|
// In place: what `unstringify` answers is the object it was given.
|
|
47
47
|
unstringify(raw);
|
|
48
48
|
const { authToken, deprecatedSettings, jwt } = resolveTokenSettings(raw.security);
|
|
49
|
+
const { ignoredSettings, storageEngine } = resolveStorageEngine(raw.services.storageEngine);
|
|
49
50
|
const loaded = {
|
|
50
51
|
...raw,
|
|
51
52
|
security: { ...raw.security, authToken, jwt },
|
|
53
|
+
services: { ...raw.services, storageEngine },
|
|
52
54
|
};
|
|
53
55
|
checkLimitsConfig(loaded);
|
|
54
56
|
checkHttpOptions(loaded);
|
|
@@ -64,6 +66,7 @@ function loadConfig() {
|
|
|
64
66
|
seed: Buffer.from("^m&mOISKBvb1xpl1mRsrylaQXpjb&IJX"),
|
|
65
67
|
},
|
|
66
68
|
deprecatedSettings,
|
|
69
|
+
ignoredSettings,
|
|
67
70
|
notifiableProtocols: [],
|
|
68
71
|
},
|
|
69
72
|
version: package_json_1.default.version,
|
|
@@ -75,19 +78,51 @@ function loadConfig() {
|
|
|
75
78
|
return config;
|
|
76
79
|
}
|
|
77
80
|
/**
|
|
78
|
-
* The packaged defaults, minus the
|
|
79
|
-
*
|
|
80
|
-
*
|
|
81
|
-
*
|
|
82
|
-
*
|
|
81
|
+
* The packaged defaults, minus the ones Kuzzle must tell apart from a value
|
|
82
|
+
* the user set, applied after `rc` has merged the configuration:
|
|
83
|
+
*
|
|
84
|
+
* - the values of `security.authToken` and of its deprecated spelling
|
|
85
|
+
* `security.jwt`: both sections ship the same non-null defaults, so once
|
|
86
|
+
* merged nothing tells a user's `jwt.expiresIn` from the packaged one. Left
|
|
87
|
+
* empty here, they hold only what the user set, and
|
|
88
|
+
* {@link resolveTokenSettings} applies the defaults after;
|
|
89
|
+
* - `services.storageEngine.majorVersion`, ignored when a storage driver is
|
|
90
|
+
* set: {@link resolveStorageEngine} reports it then, and applies the default.
|
|
83
91
|
*
|
|
84
92
|
* A shallow copy: the other sections stay the packaged objects `rc` merges
|
|
85
93
|
* into, as before.
|
|
86
94
|
*/
|
|
87
|
-
function
|
|
95
|
+
function withoutUnsetDefaults(defaults) {
|
|
88
96
|
const authToken = {};
|
|
89
97
|
const jwt = {};
|
|
90
|
-
|
|
98
|
+
const storageEngine = {
|
|
99
|
+
...defaults.services.storageEngine,
|
|
100
|
+
};
|
|
101
|
+
delete storageEngine.majorVersion;
|
|
102
|
+
return {
|
|
103
|
+
...defaults,
|
|
104
|
+
security: { ...defaults.security, authToken, jwt },
|
|
105
|
+
services: { ...defaults.services, storageEngine },
|
|
106
|
+
};
|
|
107
|
+
}
|
|
108
|
+
/**
|
|
109
|
+
* Applies the default `majorVersion`. `ignoredSettings` lists it when the
|
|
110
|
+
* user set it along with a storage `driver`, which `majorVersion` does not
|
|
111
|
+
* select: logged as a warning when the storage engine starts.
|
|
112
|
+
*/
|
|
113
|
+
function resolveStorageEngine(storageEngine) {
|
|
114
|
+
const ignoredSettings = storageEngine.driver !== undefined &&
|
|
115
|
+
storageEngine.majorVersion !== undefined
|
|
116
|
+
? ["services.storageEngine.majorVersion"]
|
|
117
|
+
: [];
|
|
118
|
+
return {
|
|
119
|
+
ignoredSettings,
|
|
120
|
+
storageEngine: {
|
|
121
|
+
...storageEngine,
|
|
122
|
+
majorVersion: storageEngine.majorVersion ??
|
|
123
|
+
default_config_1.default.services.storageEngine.majorVersion,
|
|
124
|
+
},
|
|
125
|
+
};
|
|
91
126
|
}
|
|
92
127
|
/**
|
|
93
128
|
* Resolves the authentication token settings: for each one, the value set
|
|
@@ -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
|
/**
|