kuzzle 2.19.2 → 2.19.3
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/lib/api/controllers/adminController.js +94 -80
- package/lib/api/controllers/authController.js +239 -212
- package/lib/api/controllers/baseController.js +89 -51
- package/lib/api/controllers/bulkController.js +62 -49
- package/lib/api/controllers/clusterController.js +6 -8
- package/lib/api/controllers/collectionController.js +140 -129
- package/lib/api/controllers/debugController.d.ts +2 -2
- package/lib/api/controllers/debugController.js +33 -31
- package/lib/api/controllers/documentController.js +365 -274
- package/lib/api/controllers/index.js +13 -13
- package/lib/api/controllers/indexController.js +46 -50
- package/lib/api/controllers/memoryStorageController.js +410 -360
- package/lib/api/controllers/realtimeController.js +37 -36
- package/lib/api/controllers/securityController.js +553 -412
- package/lib/api/controllers/serverController.js +111 -104
- package/lib/api/documentExtractor.js +75 -68
- package/lib/api/funnel.js +411 -312
- package/lib/api/httpRoutes.js +1493 -324
- package/lib/api/openapi/OpenApiManager.d.ts +1 -1
- package/lib/api/openapi/OpenApiManager.js +22 -22
- package/lib/api/openapi/components/document/count.yaml +1 -1
- package/lib/api/openapi/components/document/create.yaml +2 -2
- package/lib/api/openapi/components/document/delete.yaml +1 -1
- package/lib/api/openapi/components/document/deleteByQuery.yaml +1 -1
- package/lib/api/openapi/components/document/exists.yaml +1 -1
- package/lib/api/openapi/components/document/get.yaml +2 -2
- package/lib/api/openapi/components/document/index.js +12 -12
- package/lib/api/openapi/components/document/replace.yaml +1 -1
- package/lib/api/openapi/components/document/scroll.yaml +1 -1
- package/lib/api/openapi/components/document/validate.yaml +1 -1
- package/lib/api/openapi/components/index.d.ts +2 -2
- package/lib/api/openapi/components/index.js +1 -1
- package/lib/api/openapi/components/security/index.js +1 -1
- package/lib/api/openapi/components/security/upsertUser.yaml +2 -3
- package/lib/api/openapi/index.d.ts +1 -1
- package/lib/api/openapi/openApiGenerator.d.ts +1 -1
- package/lib/api/openapi/openApiGenerator.js +7 -7
- package/lib/api/rateLimiter.js +12 -13
- package/lib/api/request/index.d.ts +4 -4
- package/lib/api/request/kuzzleRequest.d.ts +9 -9
- package/lib/api/request/kuzzleRequest.js +89 -87
- package/lib/api/request/requestContext.d.ts +2 -2
- package/lib/api/request/requestContext.js +17 -17
- package/lib/api/request/requestInput.d.ts +1 -1
- package/lib/api/request/requestInput.js +19 -19
- package/lib/api/request/requestResponse.d.ts +4 -4
- package/lib/api/request/requestResponse.js +31 -33
- package/lib/cluster/command.js +48 -44
- package/lib/cluster/idCardHandler.d.ts +1 -1
- package/lib/cluster/idCardHandler.js +15 -15
- package/lib/cluster/index.js +2 -2
- package/lib/cluster/node.js +301 -269
- package/lib/cluster/publisher.js +45 -46
- package/lib/cluster/state.d.ts +5 -5
- package/lib/cluster/state.js +8 -8
- package/lib/cluster/subscriber.js +163 -113
- package/lib/cluster/workers/IDCardRenewer.js +33 -32
- package/lib/config/default.config.d.ts +1 -1
- package/lib/config/default.config.js +212 -171
- package/lib/config/documentEventAliases.js +6 -6
- package/lib/config/index.js +161 -98
- package/lib/config/sdkCompatibility.json +8 -8
- package/lib/core/auth/formatProcessing.js +7 -7
- package/lib/core/auth/passportResponse.js +7 -7
- package/lib/core/auth/passportWrapper.js +34 -30
- package/lib/core/auth/tokenManager.d.ts +2 -2
- package/lib/core/auth/tokenManager.js +11 -10
- package/lib/core/backend/applicationManager.d.ts +1 -1
- package/lib/core/backend/applicationManager.js +2 -2
- package/lib/core/backend/backend.d.ts +3 -3
- package/lib/core/backend/backend.js +34 -31
- package/lib/core/backend/backendCluster.d.ts +2 -2
- package/lib/core/backend/backendCluster.js +5 -5
- package/lib/core/backend/backendConfig.d.ts +2 -2
- package/lib/core/backend/backendConfig.js +3 -3
- package/lib/core/backend/backendController.d.ts +2 -2
- package/lib/core/backend/backendController.js +9 -10
- package/lib/core/backend/backendErrors.d.ts +3 -3
- package/lib/core/backend/backendErrors.js +2 -1
- package/lib/core/backend/backendHook.d.ts +2 -2
- package/lib/core/backend/backendHook.js +5 -5
- package/lib/core/backend/backendImport.d.ts +3 -3
- package/lib/core/backend/backendImport.js +23 -23
- package/lib/core/backend/backendOpenApi.d.ts +2 -2
- package/lib/core/backend/backendOpenApi.js +16 -16
- package/lib/core/backend/backendPipe.d.ts +2 -2
- package/lib/core/backend/backendPipe.js +6 -6
- package/lib/core/backend/backendPlugin.d.ts +4 -4
- package/lib/core/backend/backendPlugin.js +14 -14
- package/lib/core/backend/backendStorage.d.ts +2 -2
- package/lib/core/backend/backendStorage.js +1 -2
- package/lib/core/backend/backendVault.d.ts +2 -2
- package/lib/core/backend/backendVault.js +3 -3
- package/lib/core/backend/index.d.ts +14 -14
- package/lib/core/backend/internalLogger.d.ts +1 -1
- package/lib/core/backend/internalLogger.js +5 -5
- package/lib/core/cache/cacheDbEnum.js +4 -4
- package/lib/core/cache/cacheEngine.js +79 -85
- package/lib/core/network/accessLogger.js +126 -120
- package/lib/core/network/clientConnection.js +5 -5
- package/lib/core/network/context.js +8 -8
- package/lib/core/network/entryPoint.js +100 -85
- package/lib/core/network/httpRouter/index.js +63 -60
- package/lib/core/network/httpRouter/routeHandler.js +18 -19
- package/lib/core/network/httpRouter/routePart.js +23 -19
- package/lib/core/network/protocolManifest.js +3 -3
- package/lib/core/network/protocols/httpMessage.js +8 -10
- package/lib/core/network/protocols/httpwsProtocol.js +305 -250
- package/lib/core/network/protocols/internalProtocol.js +27 -24
- package/lib/core/network/protocols/mqttProtocol.js +106 -96
- package/lib/core/network/protocols/protocol.js +20 -17
- package/lib/core/network/router.js +56 -46
- package/lib/core/plugin/plugin.js +151 -120
- package/lib/core/plugin/pluginContext.d.ts +7 -7
- package/lib/core/plugin/pluginContext.js +48 -44
- package/lib/core/plugin/pluginManifest.js +13 -12
- package/lib/core/plugin/pluginRepository.js +26 -27
- package/lib/core/plugin/pluginsManager.js +425 -304
- package/lib/core/plugin/privilegedContext.js +3 -3
- package/lib/core/realtime/actionEnum.js +1 -1
- package/lib/core/realtime/channel.d.ts +1 -1
- package/lib/core/realtime/channel.js +22 -22
- package/lib/core/realtime/connectionRooms.d.ts +1 -1
- package/lib/core/realtime/hotelClerk.d.ts +2 -2
- package/lib/core/realtime/hotelClerk.js +53 -50
- package/lib/core/realtime/index.js +5 -5
- package/lib/core/realtime/notification/document.js +25 -25
- package/lib/core/realtime/notification/index.js +4 -4
- package/lib/core/realtime/notification/server.js +3 -3
- package/lib/core/realtime/notification/user.js +4 -4
- package/lib/core/realtime/notifier.js +113 -75
- package/lib/core/realtime/room.d.ts +1 -1
- package/lib/core/realtime/subscription.d.ts +1 -1
- package/lib/core/realtime/subscription.js +1 -1
- package/lib/core/security/index.js +8 -8
- package/lib/core/security/profileRepository.d.ts +6 -6
- package/lib/core/security/profileRepository.js +48 -45
- package/lib/core/security/roleRepository.js +127 -115
- package/lib/core/security/securityLoader.js +70 -63
- package/lib/core/security/tokenRepository.js +132 -118
- package/lib/core/security/userRepository.js +104 -88
- package/lib/core/shared/KoncordeWrapper.d.ts +1 -1
- package/lib/core/shared/KoncordeWrapper.js +3 -1
- package/lib/core/shared/abstractManifest.js +22 -23
- package/lib/core/shared/repository.js +69 -67
- package/lib/core/shared/sdk/embeddedSdk.d.ts +2 -2
- package/lib/core/shared/sdk/embeddedSdk.js +36 -32
- package/lib/core/shared/sdk/funnelProtocol.d.ts +1 -1
- package/lib/core/shared/sdk/funnelProtocol.js +11 -11
- package/lib/core/shared/sdk/impersonatedSdk.js +19 -18
- package/lib/core/shared/store.js +127 -32
- package/lib/core/statistics/index.js +2 -2
- package/lib/core/statistics/statistics.js +99 -85
- package/lib/core/storage/clientAdapter.js +219 -136
- package/lib/core/storage/indexCache.js +3 -3
- package/lib/core/storage/storageEngine.js +10 -13
- package/lib/core/storage/storeScopeEnum.js +3 -3
- package/lib/core/validation/baseType.js +12 -10
- package/lib/core/validation/index.js +2 -2
- package/lib/core/validation/types/anything.js +4 -4
- package/lib/core/validation/types/boolean.js +7 -7
- package/lib/core/validation/types/date.js +165 -131
- package/lib/core/validation/types/email.js +18 -21
- package/lib/core/validation/types/enum.js +34 -21
- package/lib/core/validation/types/geoPoint.js +7 -7
- package/lib/core/validation/types/geoShape.js +148 -125
- package/lib/core/validation/types/integer.js +9 -9
- package/lib/core/validation/types/ipAddress.js +17 -19
- package/lib/core/validation/types/numeric.js +36 -29
- package/lib/core/validation/types/object.js +19 -19
- package/lib/core/validation/types/string.js +36 -29
- package/lib/core/validation/types/url.js +17 -19
- package/lib/core/validation/validation.js +422 -378
- package/lib/kerror/codes/1-services.json +7 -1
- package/lib/kerror/codes/4-plugin.json +2 -2
- package/lib/kerror/codes/index.js +85 -63
- package/lib/kerror/errors/badRequestError.d.ts +1 -1
- package/lib/kerror/errors/externalServiceError.d.ts +1 -1
- package/lib/kerror/errors/forbiddenError.d.ts +1 -1
- package/lib/kerror/errors/gatewayTimeoutError.d.ts +1 -1
- package/lib/kerror/errors/index.d.ts +15 -15
- package/lib/kerror/errors/internalError.d.ts +1 -1
- package/lib/kerror/errors/kuzzleError.d.ts +1 -1
- package/lib/kerror/errors/multipleErrorsError.d.ts +1 -1
- package/lib/kerror/errors/multipleErrorsError.js +1 -1
- package/lib/kerror/errors/notFoundError.d.ts +1 -1
- package/lib/kerror/errors/partialError.d.ts +1 -1
- package/lib/kerror/errors/partialError.js +1 -1
- package/lib/kerror/errors/pluginImplementationError.d.ts +1 -1
- package/lib/kerror/errors/pluginImplementationError.js +2 -1
- package/lib/kerror/errors/preconditionError.d.ts +1 -1
- package/lib/kerror/errors/serviceUnavailableError.d.ts +1 -1
- package/lib/kerror/errors/sizeLimitError.d.ts +1 -1
- package/lib/kerror/errors/tooManyRequestsError.d.ts +1 -1
- package/lib/kerror/errors/unauthorizedError.d.ts +1 -1
- package/lib/kerror/index.d.ts +3 -3
- package/lib/kerror/index.js +17 -16
- package/lib/kuzzle/dumpGenerator.js +130 -114
- package/lib/kuzzle/event/kuzzleEventEmitter.js +96 -70
- package/lib/kuzzle/event/pipeRunner.js +25 -24
- package/lib/kuzzle/event/waterfall.js +13 -15
- package/lib/kuzzle/index.js +2 -2
- package/lib/kuzzle/internalIndexHandler.js +80 -59
- package/lib/kuzzle/kuzzle.js +99 -99
- package/lib/kuzzle/kuzzleStateEnum.js +1 -1
- package/lib/kuzzle/log.js +23 -18
- package/lib/kuzzle/vault.js +34 -19
- package/lib/model/security/profile.d.ts +3 -3
- package/lib/model/security/profile.js +38 -37
- package/lib/model/security/rights.js +5 -5
- package/lib/model/security/role.d.ts +3 -3
- package/lib/model/security/role.js +25 -26
- package/lib/model/security/token.d.ts +1 -1
- package/lib/model/security/token.js +4 -4
- package/lib/model/security/user.d.ts +2 -2
- package/lib/model/security/user.js +9 -9
- package/lib/model/storage/apiKey.js +43 -33
- package/lib/model/storage/baseModel.js +49 -45
- package/lib/service/cache/redis.js +60 -55
- package/lib/service/service.js +17 -17
- package/lib/service/storage/elasticsearch.js +839 -755
- package/lib/service/storage/esWrapper.js +103 -86
- package/lib/service/storage/queryTranslator.js +52 -59
- package/lib/types/Controller.d.ts +3 -3
- package/lib/types/ControllerDefinition.d.ts +3 -3
- package/lib/types/DebugModule.d.ts +2 -2
- package/lib/types/DebugModule.js +1 -1
- package/lib/types/Global.d.ts +1 -1
- package/lib/types/HttpStream.d.ts +2 -1
- package/lib/types/HttpStream.js +7 -5
- package/lib/types/Kuzzle.d.ts +1 -1
- package/lib/types/KuzzleDocument.d.ts +1 -1
- package/lib/types/OpenApiDefinition.d.ts +1 -1
- package/lib/types/PasswordPolicy.d.ts +1 -1
- package/lib/types/Plugin.d.ts +6 -6
- package/lib/types/Plugin.js +2 -2
- package/lib/types/Policy.d.ts +1 -1
- package/lib/types/RequestPayload.d.ts +1 -1
- package/lib/types/ResponsePayload.d.ts +1 -1
- package/lib/types/Token.d.ts +1 -1
- package/lib/types/User.d.ts +1 -1
- package/lib/types/config/DumpConfiguration.d.ts +8 -8
- package/lib/types/config/HttpConfiguration.d.ts +1 -1
- package/lib/types/config/KuzzleConfiguration.d.ts +1 -1
- package/lib/types/config/LimitsConfiguration.d.ts +8 -8
- package/lib/types/config/PluginsConfiguration.d.ts +4 -4
- package/lib/types/config/SecurityConfiguration.d.ts +62 -62
- package/lib/types/config/ServerConfiguration.d.ts +55 -55
- package/lib/types/config/ServicesConfiguration.d.ts +2 -2
- package/lib/types/config/internalCache/InternalCacheRedisConfiguration.d.ts +10 -10
- package/lib/types/config/publicCache/PublicCacheRedisConfiguration.d.ts +3 -3
- package/lib/types/config/storageEngine/StorageEngineElasticsearchConfiguration.d.ts +194 -110
- package/lib/types/errors/ErrorDefinition.d.ts +1 -1
- package/lib/types/errors/ErrorDomains.d.ts +1 -1
- package/lib/types/index.d.ts +38 -38
- package/lib/types/realtime/RealtimeScope.d.ts +1 -1
- package/lib/types/realtime/RealtimeUsers.d.ts +1 -1
- package/lib/util/assertType.js +13 -11
- package/lib/util/async.d.ts +1 -0
- package/lib/util/async.js +61 -0
- package/lib/util/asyncStore.js +19 -21
- package/lib/util/bufferedPassThrough.d.ts +2 -2
- package/lib/util/bufferedPassThrough.js +4 -4
- package/lib/util/bytes.js +9 -13
- package/lib/util/crypto.js +1 -1
- package/lib/util/debug.js +5 -5
- package/lib/util/deprecate.js +24 -21
- package/lib/util/didYouMean.js +7 -7
- package/lib/util/dump-collection.d.ts +2 -2
- package/lib/util/dump-collection.js +26 -26
- package/lib/util/esRequest.d.ts +1 -0
- package/lib/util/esRequest.js +62 -0
- package/lib/util/extractFields.js +24 -25
- package/lib/util/inflector.js +5 -5
- package/lib/util/koncordeCompat.d.ts +2 -2
- package/lib/util/koncordeCompat.js +5 -5
- package/lib/util/memoize.js +3 -5
- package/lib/util/mutex.d.ts +19 -1
- package/lib/util/mutex.js +39 -12
- package/lib/util/name-generator.js +1331 -1331
- package/lib/util/promback.js +8 -10
- package/lib/util/readYamlFile.d.ts +1 -1
- package/lib/util/readYamlFile.js +1 -1
- package/lib/util/requestAssertions.js +34 -34
- package/lib/util/safeObject.js +5 -5
- package/lib/util/stackTrace.js +20 -22
- package/lib/util/wildcard.js +15 -15
- package/package.json +6 -6
- package/npm-shrinkwrap.json +0 -19422
package/lib/cluster/node.js
CHANGED
|
@@ -19,25 +19,25 @@
|
|
|
19
19
|
* limitations under the License.
|
|
20
20
|
*/
|
|
21
21
|
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
const os = require(
|
|
25
|
-
const net = require(
|
|
26
|
-
const assert = require(
|
|
27
|
-
|
|
28
|
-
const Bluebird = require(
|
|
29
|
-
const EventEmitter = require(
|
|
30
|
-
const _ = require(
|
|
31
|
-
|
|
32
|
-
const debug = require(
|
|
33
|
-
const { Mutex } = require(
|
|
34
|
-
const { ClusterIdCardHandler } = require(
|
|
35
|
-
const ClusterPublisher = require(
|
|
36
|
-
const ClusterSubscriber = require(
|
|
37
|
-
const ClusterState = require(
|
|
38
|
-
const ClusterCommand = require(
|
|
39
|
-
const kuzzleStateEnum = require(
|
|
40
|
-
const { fromKoncordeIndex } = require(
|
|
22
|
+
"use strict";
|
|
23
|
+
|
|
24
|
+
const os = require("os");
|
|
25
|
+
const net = require("net");
|
|
26
|
+
const assert = require("assert");
|
|
27
|
+
|
|
28
|
+
const Bluebird = require("bluebird");
|
|
29
|
+
const EventEmitter = require("eventemitter3");
|
|
30
|
+
const _ = require("lodash");
|
|
31
|
+
|
|
32
|
+
const debug = require("../util/debug")("kuzzle:cluster:sync");
|
|
33
|
+
const { Mutex } = require("../util/mutex");
|
|
34
|
+
const { ClusterIdCardHandler } = require("./idCardHandler");
|
|
35
|
+
const ClusterPublisher = require("./publisher");
|
|
36
|
+
const ClusterSubscriber = require("./subscriber");
|
|
37
|
+
const ClusterState = require("./state");
|
|
38
|
+
const ClusterCommand = require("./command");
|
|
39
|
+
const kuzzleStateEnum = require("../kuzzle/kuzzleStateEnum");
|
|
40
|
+
const { fromKoncordeIndex } = require("../util/koncordeCompat");
|
|
41
41
|
|
|
42
42
|
/**
|
|
43
43
|
* Test an IP address and determine if it's in the public or private range.
|
|
@@ -45,19 +45,23 @@ const { fromKoncordeIndex } = require('../util/koncordeCompat');
|
|
|
45
45
|
* @param {String} ip
|
|
46
46
|
* @return {Boolean}
|
|
47
47
|
*/
|
|
48
|
-
function isPrivateIP
|
|
48
|
+
function isPrivateIP(ip) {
|
|
49
49
|
if (net.isIPv6(ip)) {
|
|
50
|
-
const prefix = ip.split(
|
|
50
|
+
const prefix = ip.split(":")[0];
|
|
51
51
|
|
|
52
|
-
return (
|
|
52
|
+
return (
|
|
53
|
+
(prefix.startsWith("fd") && prefix.length === 4) || prefix === "fe80"
|
|
54
|
+
);
|
|
53
55
|
}
|
|
54
56
|
|
|
55
57
|
// IPv4
|
|
56
|
-
const exploded = ip.split(
|
|
58
|
+
const exploded = ip.split(".").map((s) => Number.parseInt(s));
|
|
57
59
|
|
|
58
|
-
return
|
|
59
|
-
|
|
60
|
-
|
|
60
|
+
return (
|
|
61
|
+
exploded[0] === 10 ||
|
|
62
|
+
(exploded[0] === 172 && exploded[1] >= 16 && exploded[1] <= 31) ||
|
|
63
|
+
(exploded[0] === 192 && exploded[1] === 168)
|
|
64
|
+
);
|
|
61
65
|
}
|
|
62
66
|
|
|
63
67
|
/**
|
|
@@ -66,23 +70,25 @@ function isPrivateIP (ip) {
|
|
|
66
70
|
* @param {String} ip
|
|
67
71
|
* @return {Boolean}
|
|
68
72
|
*/
|
|
69
|
-
function isInternalIP
|
|
73
|
+
function isInternalIP(ip) {
|
|
70
74
|
// To my knowledge, there aren't any reserved, non-loopback and non-routable
|
|
71
75
|
// IPv6 addresses
|
|
72
76
|
if (net.isIPv6(ip)) {
|
|
73
77
|
return false;
|
|
74
78
|
}
|
|
75
79
|
|
|
76
|
-
const exploded = ip.split(
|
|
80
|
+
const exploded = ip.split(".").map((s) => Number.parseInt(s));
|
|
77
81
|
|
|
78
82
|
// 127.x.x: loopback addresses are already flagged as "internal" by
|
|
79
83
|
// os.networkInterfaces.
|
|
80
|
-
return
|
|
84
|
+
return (
|
|
85
|
+
exploded[0] === 127 ||
|
|
81
86
|
// 169.254.x.x addresses are APIPA addresses: temporary and non-routable.
|
|
82
87
|
// We need to remove them from the accepted list of IP addresses
|
|
83
88
|
// (this is a "just in case" scenario: APIPA addresses are obsolete and
|
|
84
89
|
// should not be used anymore, but we never know...)
|
|
85
|
-
|
|
90
|
+
(exploded[0] === 169 && exploded[1] === 254)
|
|
91
|
+
);
|
|
86
92
|
}
|
|
87
93
|
|
|
88
94
|
/**
|
|
@@ -93,8 +99,8 @@ function isInternalIP (ip) {
|
|
|
93
99
|
* @param {String} [options.ip] Used to target public or private addresses
|
|
94
100
|
* @return {String|null}
|
|
95
101
|
*/
|
|
96
|
-
function getIP
|
|
97
|
-
const mustBePrivate = ip ===
|
|
102
|
+
function getIP({ family = "IPv4", interface: netInterface, ip } = {}) {
|
|
103
|
+
const mustBePrivate = ip === "private";
|
|
98
104
|
|
|
99
105
|
let interfaces = [];
|
|
100
106
|
|
|
@@ -107,23 +113,25 @@ function getIP ({ family = 'IPv4', interface: netInterface, ip } = {}) {
|
|
|
107
113
|
}
|
|
108
114
|
}
|
|
109
115
|
|
|
110
|
-
debug(
|
|
116
|
+
debug("Found interfaces %o", interfaces);
|
|
111
117
|
|
|
112
|
-
interfaces = interfaces.filter(n => {
|
|
113
|
-
return
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
118
|
+
interfaces = interfaces.filter((n) => {
|
|
119
|
+
return (
|
|
120
|
+
!n.internal &&
|
|
121
|
+
!isInternalIP(n.address) &&
|
|
122
|
+
n.family === family &&
|
|
123
|
+
(!ip || mustBePrivate === isPrivateIP(n.address))
|
|
124
|
+
);
|
|
117
125
|
});
|
|
118
126
|
|
|
119
|
-
debug(
|
|
127
|
+
debug("Filtered interfaces %o", interfaces);
|
|
120
128
|
|
|
121
129
|
if (interfaces.length === 0) {
|
|
122
130
|
return null;
|
|
123
131
|
}
|
|
124
132
|
|
|
125
133
|
// take the first IP from the list if no interface has been defined
|
|
126
|
-
if (!
|
|
134
|
+
if (!netInterface) {
|
|
127
135
|
return interfaces[0].address;
|
|
128
136
|
}
|
|
129
137
|
|
|
@@ -136,7 +144,6 @@ function getIP ({ family = 'IPv4', interface: netInterface, ip } = {}) {
|
|
|
136
144
|
return null;
|
|
137
145
|
}
|
|
138
146
|
|
|
139
|
-
|
|
140
147
|
/**
|
|
141
148
|
* @typedef {nodeActivityEnum}
|
|
142
149
|
*/
|
|
@@ -148,11 +155,11 @@ const nodeActivityEnum = Object.freeze({
|
|
|
148
155
|
// Handles the node logic: discovery, eviction, heartbeat, ...
|
|
149
156
|
// Dependencies: core:cache module must be started
|
|
150
157
|
class ClusterNode {
|
|
151
|
-
constructor
|
|
158
|
+
constructor() {
|
|
152
159
|
this.config = global.kuzzle.config.cluster;
|
|
153
160
|
this.heartbeatDelay = this.config.heartbeat;
|
|
154
161
|
|
|
155
|
-
const family = this.config.ipv6 ?
|
|
162
|
+
const family = this.config.ipv6 ? "IPv6" : "IPv4";
|
|
156
163
|
|
|
157
164
|
this.ip = getIP({
|
|
158
165
|
family,
|
|
@@ -160,8 +167,11 @@ class ClusterNode {
|
|
|
160
167
|
ip: this.config.ip,
|
|
161
168
|
});
|
|
162
169
|
|
|
163
|
-
debug(
|
|
164
|
-
assert(
|
|
170
|
+
debug("Found IP address: %s with config %o", this.ip, this.config);
|
|
171
|
+
assert(
|
|
172
|
+
this.ip !== null,
|
|
173
|
+
`[CLUSTER] No suitable IP address found with the provided configuration (family: ${family}, interface: ${this.config.interface}, ip: ${this.config.ip})`
|
|
174
|
+
);
|
|
165
175
|
|
|
166
176
|
this.nodeId = null;
|
|
167
177
|
this.heartbeatTimer = null;
|
|
@@ -186,11 +196,11 @@ class ClusterNode {
|
|
|
186
196
|
this.activity = [];
|
|
187
197
|
}
|
|
188
198
|
|
|
189
|
-
get syncAddress
|
|
199
|
+
get syncAddress() {
|
|
190
200
|
return `tcp://${this.ip}:${this.config.ports.sync}`;
|
|
191
201
|
}
|
|
192
202
|
|
|
193
|
-
async init
|
|
203
|
+
async init() {
|
|
194
204
|
// The publisher needs to be created and initialized before the handshake:
|
|
195
205
|
// other nodes we'll connect to during the handshake will start to subscribe
|
|
196
206
|
// to this node right away
|
|
@@ -201,7 +211,7 @@ class ClusterNode {
|
|
|
201
211
|
// and to introduce oneself to other nodes)
|
|
202
212
|
await this.command.init();
|
|
203
213
|
|
|
204
|
-
global.kuzzle.onPipe(
|
|
214
|
+
global.kuzzle.onPipe("kuzzle:shutdown", () => this.shutdown());
|
|
205
215
|
|
|
206
216
|
await this.handshake();
|
|
207
217
|
|
|
@@ -209,7 +219,9 @@ class ClusterNode {
|
|
|
209
219
|
this.registerAskEvents();
|
|
210
220
|
|
|
211
221
|
if (this.countActiveNodes() < this.config.minimumNodes) {
|
|
212
|
-
global.kuzzle.log.info(
|
|
222
|
+
global.kuzzle.log.info(
|
|
223
|
+
"[CLUSTER] Not enough nodes active. Waiting for other nodes to join the cluster..."
|
|
224
|
+
);
|
|
213
225
|
|
|
214
226
|
while (this.countActiveNodes() < this.config.minimumNodes) {
|
|
215
227
|
await Bluebird.delay(100);
|
|
@@ -223,7 +235,7 @@ class ClusterNode {
|
|
|
223
235
|
* Shutdown event: clears all timers, sends a termination status to other
|
|
224
236
|
* nodes, and removes entries from the cache
|
|
225
237
|
*/
|
|
226
|
-
async shutdown
|
|
238
|
+
async shutdown() {
|
|
227
239
|
clearInterval(this.heartbeatTimer);
|
|
228
240
|
await this.idCardHandler.dispose();
|
|
229
241
|
|
|
@@ -244,7 +256,7 @@ class ClusterNode {
|
|
|
244
256
|
* @param {number} lastMessageId - remote node last message ID
|
|
245
257
|
* @return {boolean} false if the node was already known, true otherwise
|
|
246
258
|
*/
|
|
247
|
-
async addNode
|
|
259
|
+
async addNode(id, ip, lastMessageId) {
|
|
248
260
|
if (this.remoteNodes.has(id)) {
|
|
249
261
|
return false;
|
|
250
262
|
}
|
|
@@ -259,11 +271,14 @@ class ClusterNode {
|
|
|
259
271
|
global.kuzzle.log.info(`[CLUSTER] Node "${id}" joined the cluster`);
|
|
260
272
|
this.trackActivity(id, ip, nodeActivityEnum.ADDED);
|
|
261
273
|
|
|
262
|
-
if (
|
|
263
|
-
|
|
274
|
+
if (
|
|
275
|
+
global.kuzzle.state === kuzzleStateEnum.NOT_ENOUGH_NODES &&
|
|
276
|
+
this.countActiveNodes() >= this.config.minimumNodes
|
|
264
277
|
) {
|
|
265
278
|
global.kuzzle.state = kuzzleStateEnum.RUNNING;
|
|
266
|
-
global.kuzzle.log.warn(
|
|
279
|
+
global.kuzzle.log.warn(
|
|
280
|
+
`[CLUSTER] Minimum number of nodes reached (${this.countActiveNodes()}). This node is now accepting requests again.`
|
|
281
|
+
);
|
|
267
282
|
}
|
|
268
283
|
|
|
269
284
|
return true;
|
|
@@ -276,7 +291,7 @@ class ClusterNode {
|
|
|
276
291
|
* @param {Error} [error]
|
|
277
292
|
* @return {void}
|
|
278
293
|
*/
|
|
279
|
-
async evictSelf
|
|
294
|
+
async evictSelf(reason, error = null) {
|
|
280
295
|
global.kuzzle.log.error(`[CLUSTER] ${reason}`);
|
|
281
296
|
|
|
282
297
|
if (error) {
|
|
@@ -295,19 +310,22 @@ class ClusterNode {
|
|
|
295
310
|
* @param {boolean} [options.broadcast] - broadcast the eviction to the cluster
|
|
296
311
|
* @param {string} [options.reason] - reason of eviction
|
|
297
312
|
*/
|
|
298
|
-
async evictNode
|
|
313
|
+
async evictNode(nodeId, { broadcast = false, reason = "" }) {
|
|
299
314
|
const subscriber = this.remoteNodes.get(nodeId);
|
|
300
315
|
|
|
301
|
-
if (!
|
|
316
|
+
if (!subscriber) {
|
|
302
317
|
return;
|
|
303
318
|
}
|
|
304
319
|
|
|
305
|
-
global.kuzzle.log.warn(
|
|
320
|
+
global.kuzzle.log.warn(
|
|
321
|
+
`[CLUSTER] Node "${nodeId}" evicted. Reason: ${reason}`
|
|
322
|
+
);
|
|
306
323
|
this.trackActivity(
|
|
307
324
|
nodeId,
|
|
308
325
|
subscriber.remoteNodeIP,
|
|
309
326
|
nodeActivityEnum.EVICTED,
|
|
310
|
-
reason
|
|
327
|
+
reason
|
|
328
|
+
);
|
|
311
329
|
|
|
312
330
|
await this.idCardHandler.removeNode(nodeId);
|
|
313
331
|
this.remoteNodes.delete(nodeId);
|
|
@@ -320,7 +338,11 @@ class ClusterNode {
|
|
|
320
338
|
|
|
321
339
|
if (this.countActiveNodes() < this.config.minimumNodes) {
|
|
322
340
|
global.kuzzle.state = kuzzleStateEnum.NOT_ENOUGH_NODES;
|
|
323
|
-
global.kuzzle.log.warn(
|
|
341
|
+
global.kuzzle.log.warn(
|
|
342
|
+
`[CLUSTER] Not enough nodes active (expected: ${
|
|
343
|
+
this.config.minimumNodes
|
|
344
|
+
}, active: ${this.countActiveNodes()}). Deactivating node until new ones are added.`
|
|
345
|
+
);
|
|
324
346
|
}
|
|
325
347
|
|
|
326
348
|
this.enforceClusterConsistency();
|
|
@@ -333,7 +355,7 @@ class ClusterNode {
|
|
|
333
355
|
* /!\ Do not wait for this method: it's meant to run as a background check.
|
|
334
356
|
* It'll never throw, and it'll never generate unhandled rejections.
|
|
335
357
|
*/
|
|
336
|
-
async enforceClusterConsistency
|
|
358
|
+
async enforceClusterConsistency() {
|
|
337
359
|
// Delay the check to 1 heartbeat round, to allow all nodes to update
|
|
338
360
|
// their ID cards
|
|
339
361
|
await Bluebird.delay(this.heartbeatDelay);
|
|
@@ -350,7 +372,7 @@ class ClusterNode {
|
|
|
350
372
|
|
|
351
373
|
if (topology.length !== idCards.length) {
|
|
352
374
|
topology = topology.sort();
|
|
353
|
-
const found = splits.some(split => {
|
|
375
|
+
const found = splits.some((split) => {
|
|
354
376
|
if (split.length !== topology.length) {
|
|
355
377
|
return false;
|
|
356
378
|
}
|
|
@@ -358,7 +380,7 @@ class ClusterNode {
|
|
|
358
380
|
return split.every((id, index) => id === topology[index]);
|
|
359
381
|
});
|
|
360
382
|
|
|
361
|
-
if (!
|
|
383
|
+
if (!found) {
|
|
362
384
|
splits.push(topology);
|
|
363
385
|
}
|
|
364
386
|
}
|
|
@@ -382,21 +404,20 @@ class ClusterNode {
|
|
|
382
404
|
// shut down.
|
|
383
405
|
|
|
384
406
|
// First remove every non existing node from topologies
|
|
385
|
-
splits = splits.map(
|
|
386
|
-
topology =>
|
|
387
|
-
|
|
388
|
-
));
|
|
407
|
+
splits = splits.map((topology) =>
|
|
408
|
+
topology.filter((nodeId) => idCards.find((card) => card.id === nodeId))
|
|
409
|
+
);
|
|
389
410
|
|
|
390
411
|
splits = splits.sort((a, b) => a.length - b.length);
|
|
391
|
-
const eligibleSplits = splits
|
|
392
|
-
|
|
412
|
+
const eligibleSplits = splits.filter(
|
|
413
|
+
(split) => split.length === splits[0].length
|
|
414
|
+
);
|
|
393
415
|
|
|
394
416
|
let candidates;
|
|
395
417
|
|
|
396
418
|
if (eligibleSplits.length === 1) {
|
|
397
419
|
candidates = eligibleSplits[0];
|
|
398
|
-
}
|
|
399
|
-
else {
|
|
420
|
+
} else {
|
|
400
421
|
// Beware: search isolated nodes in ALL the splits, not only the
|
|
401
422
|
// smallest ones
|
|
402
423
|
let isolatedNodes = _.xor(...splits);
|
|
@@ -414,35 +435,37 @@ class ClusterNode {
|
|
|
414
435
|
let youngestNode;
|
|
415
436
|
|
|
416
437
|
for (let i = 0; i < isolatedNodes.length; i++) {
|
|
417
|
-
const idCard = idCards.find(card => card.id === isolatedNodes[i]);
|
|
418
|
-
if (!
|
|
438
|
+
const idCard = idCards.find((card) => card.id === isolatedNodes[i]);
|
|
439
|
+
if (!youngestNode || idCard.birthdate > youngestNode.birthdate) {
|
|
419
440
|
youngestNode = idCard;
|
|
420
441
|
}
|
|
421
442
|
}
|
|
422
443
|
|
|
423
444
|
if (isIsolated) {
|
|
424
|
-
for (let i = 0; !
|
|
445
|
+
for (let i = 0; !candidates && i < eligibleSplits.length; i++) {
|
|
425
446
|
if (eligibleSplits[i].includes(youngestNode.id)) {
|
|
426
447
|
candidates = _.intersection(eligibleSplits[i], isolatedNodes);
|
|
427
448
|
}
|
|
428
449
|
}
|
|
429
|
-
}
|
|
430
|
-
else {
|
|
450
|
+
} else {
|
|
431
451
|
candidates = [youngestNode.id];
|
|
432
452
|
}
|
|
433
453
|
}
|
|
434
454
|
|
|
435
455
|
if (candidates.includes(this.nodeId)) {
|
|
436
|
-
global.kuzzle.log.error(
|
|
456
|
+
global.kuzzle.log.error(
|
|
457
|
+
"[CLUSTER] Network split detected. This node is outside the cluster: shutting down."
|
|
458
|
+
);
|
|
437
459
|
this.shutdownNode();
|
|
438
460
|
return;
|
|
439
461
|
}
|
|
440
462
|
|
|
441
463
|
// Rerun the cluster consistency check
|
|
442
464
|
await this.enforceClusterConsistency();
|
|
443
|
-
}
|
|
444
|
-
|
|
445
|
-
|
|
465
|
+
} catch (err) {
|
|
466
|
+
global.kuzzle.log.error(
|
|
467
|
+
"[CLUSTER] Unexpected exception caught during a cluster consistency check. Shutting down..."
|
|
468
|
+
);
|
|
446
469
|
global.kuzzle.log.error(err.stack);
|
|
447
470
|
this.shutdownNode();
|
|
448
471
|
}
|
|
@@ -455,15 +478,15 @@ class ClusterNode {
|
|
|
455
478
|
*
|
|
456
479
|
* @return {void}
|
|
457
480
|
*/
|
|
458
|
-
async handshake
|
|
459
|
-
const handshakeTimeout = setTimeout(
|
|
460
|
-
(
|
|
461
|
-
|
|
462
|
-
|
|
463
|
-
|
|
464
|
-
|
|
481
|
+
async handshake() {
|
|
482
|
+
const handshakeTimeout = setTimeout(() => {
|
|
483
|
+
global.kuzzle.log.error(
|
|
484
|
+
`[CLUSTER] Failed to join the cluster: timed out (joinTimeout: ${this.config.joinTimeout}ms)`
|
|
485
|
+
);
|
|
486
|
+
this.shutdownNode();
|
|
487
|
+
}, this.config.joinTimeout);
|
|
465
488
|
|
|
466
|
-
const mutex = new Mutex(
|
|
489
|
+
const mutex = new Mutex("clusterHandshake", {
|
|
467
490
|
timeout: this.config.joinTimeout,
|
|
468
491
|
});
|
|
469
492
|
|
|
@@ -474,21 +497,21 @@ class ClusterNode {
|
|
|
474
497
|
// to prevent race conditions (other nodes attempting to connect to this
|
|
475
498
|
// node while it's still initializing)
|
|
476
499
|
await this.idCardHandler.createIdCard();
|
|
477
|
-
debug(
|
|
500
|
+
debug("[CLUSTER] ID Card created");
|
|
478
501
|
|
|
479
502
|
this.nodeId = this.idCardHandler.nodeId;
|
|
480
503
|
|
|
481
504
|
await this.startHeartbeat();
|
|
482
|
-
debug(
|
|
505
|
+
debug("[CLUSTER] Start heartbeat");
|
|
483
506
|
|
|
484
507
|
let retried = false;
|
|
485
508
|
let fullState = null;
|
|
486
509
|
let nodes;
|
|
487
510
|
|
|
488
|
-
debug(
|
|
511
|
+
debug("[CLUSTER] Start retrieving full state..");
|
|
489
512
|
do {
|
|
490
513
|
nodes = await this.idCardHandler.getRemoteIdCards();
|
|
491
|
-
debug(
|
|
514
|
+
debug("[CLUSTER] %s remote nodes discovered", nodes.length);
|
|
492
515
|
|
|
493
516
|
// No other nodes detected = no handshake required
|
|
494
517
|
if (nodes.length === 0) {
|
|
@@ -497,10 +520,12 @@ class ClusterNode {
|
|
|
497
520
|
}
|
|
498
521
|
|
|
499
522
|
// Verify that no other node share the same IP address as this one
|
|
500
|
-
const duplicate = nodes.filter(node => node.ip === this.ip);
|
|
523
|
+
const duplicate = nodes.filter((node) => node.ip === this.ip);
|
|
501
524
|
|
|
502
525
|
if (duplicate.length > 0) {
|
|
503
|
-
global.kuzzle.log.error(
|
|
526
|
+
global.kuzzle.log.error(
|
|
527
|
+
`[CLUSTER] Another node share the same IP address as this one (${this.ip}): ${duplicate[0].id}. Shutting down.`
|
|
528
|
+
);
|
|
504
529
|
this.shutdownNode();
|
|
505
530
|
return;
|
|
506
531
|
}
|
|
@@ -511,7 +536,7 @@ class ClusterNode {
|
|
|
511
536
|
this.remoteNodes.set(id, subscriber);
|
|
512
537
|
return subscriber.init();
|
|
513
538
|
});
|
|
514
|
-
debug(
|
|
539
|
+
debug("[CLUSTER] Successfully subscribed to nodes");
|
|
515
540
|
|
|
516
541
|
fullState = await this.command.getFullState(nodes);
|
|
517
542
|
|
|
@@ -522,7 +547,9 @@ class ClusterNode {
|
|
|
522
547
|
// down.
|
|
523
548
|
if (fullState === null) {
|
|
524
549
|
if (retried) {
|
|
525
|
-
global.kuzzle.log.error(
|
|
550
|
+
global.kuzzle.log.error(
|
|
551
|
+
"[CLUSTER] Could not connect to discovered cluster nodes (network split detected). Shutting down."
|
|
552
|
+
);
|
|
526
553
|
this.shutdownNode();
|
|
527
554
|
return;
|
|
528
555
|
}
|
|
@@ -536,57 +563,58 @@ class ClusterNode {
|
|
|
536
563
|
// Waits for a redis heartbeat round
|
|
537
564
|
retried = true;
|
|
538
565
|
const retryDelay = this.heartbeatDelay * 1.5;
|
|
539
|
-
global.kuzzle.log.warn(
|
|
566
|
+
global.kuzzle.log.warn(
|
|
567
|
+
`[CLUSTER] Unable to connect to discovered cluster nodes. Retrying in ${retryDelay}ms...`
|
|
568
|
+
);
|
|
540
569
|
await Bluebird.delay(retryDelay);
|
|
541
570
|
}
|
|
542
|
-
}
|
|
543
|
-
|
|
544
|
-
debug('[CLUSTER] Fullstate retrieved, loading into node..');
|
|
571
|
+
} while (fullState === null);
|
|
572
|
+
debug("[CLUSTER] Fullstate retrieved, loading into node..");
|
|
545
573
|
|
|
546
574
|
await this.fullState.loadFullState(fullState);
|
|
547
|
-
this.activity = fullState.activity
|
|
548
|
-
? fullState.activity
|
|
549
|
-
: this.activity;
|
|
575
|
+
this.activity = fullState.activity ? fullState.activity : this.activity;
|
|
550
576
|
|
|
551
|
-
debug(
|
|
577
|
+
debug("[CLUSTER] Fullstate loaded.");
|
|
552
578
|
|
|
553
579
|
const handshakeResponses = await this.command.broadcastHandshake(nodes);
|
|
554
580
|
|
|
555
|
-
debug(
|
|
581
|
+
debug("[CLUSTER] Successful handshakes with other nodes.");
|
|
556
582
|
|
|
557
583
|
// Update subscribers: start synchronizing, or unsubscribes from nodes who
|
|
558
584
|
// didn't respond
|
|
559
|
-
for (const [nodeId, handshakeData] of Object.entries(
|
|
585
|
+
for (const [nodeId, handshakeData] of Object.entries(
|
|
586
|
+
handshakeResponses
|
|
587
|
+
)) {
|
|
560
588
|
const subscriber = this.remoteNodes.get(nodeId);
|
|
561
589
|
if (handshakeData === null) {
|
|
562
590
|
subscriber.dispose();
|
|
563
591
|
this.remoteNodes.delete(nodeId);
|
|
564
|
-
}
|
|
565
|
-
else {
|
|
592
|
+
} else {
|
|
566
593
|
await this.idCardHandler.addNode(nodeId);
|
|
567
594
|
const nodesStates = fullState.nodesState || [];
|
|
568
|
-
const nodeStatus = nodesStates.find(node => node.id === nodeId);
|
|
569
|
-
subscriber.sync(
|
|
570
|
-
? nodeStatus.lastMessageId
|
|
571
|
-
|
|
572
|
-
global.kuzzle.log.info(
|
|
595
|
+
const nodeStatus = nodesStates.find((node) => node.id === nodeId);
|
|
596
|
+
subscriber.sync(
|
|
597
|
+
nodeStatus ? nodeStatus.lastMessageId : handshakeData.lastMessageId
|
|
598
|
+
);
|
|
599
|
+
global.kuzzle.log.info(
|
|
600
|
+
`[CLUSTER] Successfully completed the handshake with node ${nodeId}`
|
|
601
|
+
);
|
|
573
602
|
}
|
|
574
603
|
}
|
|
575
604
|
|
|
576
|
-
global.kuzzle.log.info(
|
|
605
|
+
global.kuzzle.log.info("[CLUSTER] Successfully joined the cluster.");
|
|
577
606
|
this.trackActivity(this.nodeId, this.ip, nodeActivityEnum.ADDED);
|
|
578
|
-
}
|
|
579
|
-
finally {
|
|
607
|
+
} finally {
|
|
580
608
|
clearTimeout(handshakeTimeout);
|
|
581
609
|
await mutex.unlock();
|
|
582
610
|
}
|
|
583
611
|
}
|
|
584
612
|
|
|
585
|
-
countActiveNodes
|
|
613
|
+
countActiveNodes() {
|
|
586
614
|
return this.remoteNodes.size + 1;
|
|
587
615
|
}
|
|
588
616
|
|
|
589
|
-
startHeartbeat
|
|
617
|
+
startHeartbeat() {
|
|
590
618
|
this.heartbeatTimer = setInterval(() => {
|
|
591
619
|
this.publisher.sendHeartbeat(this.syncAddress);
|
|
592
620
|
}, this.heartbeatDelay);
|
|
@@ -600,14 +628,14 @@ class ClusterNode {
|
|
|
600
628
|
* @param {nodeActivityEnum} event
|
|
601
629
|
* @param {string} [reason]
|
|
602
630
|
*/
|
|
603
|
-
trackActivity
|
|
631
|
+
trackActivity(id, ip, event, reason) {
|
|
604
632
|
if (this.activity.length > this.activityMaxLength) {
|
|
605
633
|
this.activity.shift();
|
|
606
634
|
}
|
|
607
635
|
|
|
608
636
|
this.activity.push({
|
|
609
637
|
address: ip,
|
|
610
|
-
date:
|
|
638
|
+
date: new Date().toISOString(),
|
|
611
639
|
event,
|
|
612
640
|
id,
|
|
613
641
|
reason,
|
|
@@ -618,13 +646,13 @@ class ClusterNode {
|
|
|
618
646
|
* Returns the full status of the cluster
|
|
619
647
|
* @return {Object}
|
|
620
648
|
*/
|
|
621
|
-
async getStatus
|
|
649
|
+
async getStatus() {
|
|
622
650
|
const status = {
|
|
623
651
|
activeNodes: 0,
|
|
624
652
|
activity: this.activity.map(({ address, date, event, id, reason }) => ({
|
|
625
653
|
address,
|
|
626
654
|
date,
|
|
627
|
-
event: event === nodeActivityEnum.ADDED ?
|
|
655
|
+
event: event === nodeActivityEnum.ADDED ? "joined" : "evicted",
|
|
628
656
|
id,
|
|
629
657
|
reason,
|
|
630
658
|
})),
|
|
@@ -649,7 +677,7 @@ class ClusterNode {
|
|
|
649
677
|
/**
|
|
650
678
|
* Registers ask events
|
|
651
679
|
*/
|
|
652
|
-
registerAskEvents
|
|
680
|
+
registerAskEvents() {
|
|
653
681
|
/**
|
|
654
682
|
* Removes a room from the full state, and only for this node.
|
|
655
683
|
* Removes the room from Koncorde if, and only if, no other node uses it.
|
|
@@ -657,9 +685,9 @@ class ClusterNode {
|
|
|
657
685
|
* @param {string} roomId
|
|
658
686
|
* @return {void}
|
|
659
687
|
*/
|
|
660
|
-
global.kuzzle.onAsk(
|
|
661
|
-
|
|
662
|
-
|
|
688
|
+
global.kuzzle.onAsk("cluster:realtime:room:remove", (roomId) =>
|
|
689
|
+
this.removeRealtimeRoom(roomId)
|
|
690
|
+
);
|
|
663
691
|
|
|
664
692
|
/**
|
|
665
693
|
* Returns the total number of subscribers on all nodes for the provided
|
|
@@ -668,18 +696,18 @@ class ClusterNode {
|
|
|
668
696
|
* @param {string} roomId
|
|
669
697
|
* @returns {Number}
|
|
670
698
|
*/
|
|
671
|
-
global.kuzzle.onAsk(
|
|
672
|
-
|
|
673
|
-
|
|
699
|
+
global.kuzzle.onAsk("cluster:realtime:room:count", (roomId) =>
|
|
700
|
+
this.countRealtimeSubscribers(roomId)
|
|
701
|
+
);
|
|
674
702
|
|
|
675
703
|
/**
|
|
676
704
|
* Returns the list of existing rooms in the cluster
|
|
677
705
|
*
|
|
678
706
|
* @returns {Object}
|
|
679
707
|
*/
|
|
680
|
-
global.kuzzle.onAsk(
|
|
681
|
-
|
|
682
|
-
|
|
708
|
+
global.kuzzle.onAsk("cluster:realtime:room:list", () =>
|
|
709
|
+
this.fullState.listRealtimeRooms()
|
|
710
|
+
);
|
|
683
711
|
|
|
684
712
|
/**
|
|
685
713
|
* Returns the requested room. Used to create a room on the fly on this node
|
|
@@ -688,9 +716,9 @@ class ClusterNode {
|
|
|
688
716
|
* @param {string} roomId
|
|
689
717
|
* @returns {NormalizedFilter}
|
|
690
718
|
*/
|
|
691
|
-
global.kuzzle.onAsk(
|
|
692
|
-
|
|
693
|
-
|
|
719
|
+
global.kuzzle.onAsk("cluster:realtime:filters:get", (roomId) =>
|
|
720
|
+
this.fullState.getNormalizedFilters(roomId)
|
|
721
|
+
);
|
|
694
722
|
|
|
695
723
|
/**
|
|
696
724
|
* Broadcasts an event to other nodes
|
|
@@ -698,9 +726,9 @@ class ClusterNode {
|
|
|
698
726
|
* @param {string} event name
|
|
699
727
|
* @param {Object} payload - event payload
|
|
700
728
|
*/
|
|
701
|
-
global.kuzzle.onAsk(
|
|
702
|
-
|
|
703
|
-
|
|
729
|
+
global.kuzzle.onAsk("cluster:event:broadcast", (event, payload) =>
|
|
730
|
+
this.broadcast(event, payload)
|
|
731
|
+
);
|
|
704
732
|
|
|
705
733
|
/**
|
|
706
734
|
* Listens to a cluster-wide event
|
|
@@ -708,9 +736,9 @@ class ClusterNode {
|
|
|
708
736
|
* @param {string} event name
|
|
709
737
|
* @param {Function} fn - event listener
|
|
710
738
|
*/
|
|
711
|
-
global.kuzzle.onAsk(
|
|
712
|
-
|
|
713
|
-
|
|
739
|
+
global.kuzzle.onAsk("cluster:event:on", (event, fn) =>
|
|
740
|
+
this.eventEmitter.on(event, fn)
|
|
741
|
+
);
|
|
714
742
|
|
|
715
743
|
/**
|
|
716
744
|
* Listens to a cluster-wide event once.
|
|
@@ -718,9 +746,9 @@ class ClusterNode {
|
|
|
718
746
|
* @param {string} event name
|
|
719
747
|
* @param {Function} fn - event listener
|
|
720
748
|
*/
|
|
721
|
-
global.kuzzle.onAsk(
|
|
722
|
-
|
|
723
|
-
|
|
749
|
+
global.kuzzle.onAsk("cluster:event:once", (event, fn) =>
|
|
750
|
+
this.eventEmitter.once(event, fn)
|
|
751
|
+
);
|
|
724
752
|
|
|
725
753
|
/**
|
|
726
754
|
* Removes a listener from an event
|
|
@@ -728,23 +756,23 @@ class ClusterNode {
|
|
|
728
756
|
* @param {string} event name
|
|
729
757
|
* @param {Function} fn - event listener
|
|
730
758
|
*/
|
|
731
|
-
global.kuzzle.onAsk(
|
|
732
|
-
|
|
733
|
-
|
|
759
|
+
global.kuzzle.onAsk("cluster:event:off", (event, fn) =>
|
|
760
|
+
this.eventEmitter.removeListener(event, fn)
|
|
761
|
+
);
|
|
734
762
|
|
|
735
763
|
/**
|
|
736
764
|
* Removes all listeners from an event
|
|
737
765
|
*
|
|
738
766
|
* @param {string} event name
|
|
739
767
|
*/
|
|
740
|
-
global.kuzzle.onAsk(
|
|
741
|
-
|
|
742
|
-
|
|
768
|
+
global.kuzzle.onAsk("cluster:event:removeAllListeners", (event) =>
|
|
769
|
+
this.eventEmitter.removeAllListeners(event)
|
|
770
|
+
);
|
|
743
771
|
|
|
744
772
|
/**
|
|
745
773
|
* Returns the full status of the cluster
|
|
746
774
|
*/
|
|
747
|
-
global.kuzzle.onAsk(
|
|
775
|
+
global.kuzzle.onAsk("cluster:status:get", () => this.getStatus());
|
|
748
776
|
}
|
|
749
777
|
|
|
750
778
|
/**
|
|
@@ -752,121 +780,118 @@ class ClusterNode {
|
|
|
752
780
|
*
|
|
753
781
|
* @return {void}
|
|
754
782
|
*/
|
|
755
|
-
registerEvents
|
|
756
|
-
global.kuzzle.on(
|
|
757
|
-
|
|
758
|
-
|
|
783
|
+
registerEvents() {
|
|
784
|
+
global.kuzzle.on("admin:afterRefreshIndexCache", () =>
|
|
785
|
+
this.onIndexCacheRefreshed()
|
|
786
|
+
);
|
|
759
787
|
|
|
760
|
-
global.kuzzle.onCall(
|
|
761
|
-
|
|
762
|
-
|
|
788
|
+
global.kuzzle.onCall("core:realtime:room:create:after", (payload) =>
|
|
789
|
+
this.onNewRealtimeRoom(payload)
|
|
790
|
+
);
|
|
763
791
|
|
|
764
|
-
global.kuzzle.onCall(
|
|
765
|
-
|
|
766
|
-
|
|
792
|
+
global.kuzzle.onCall("core:realtime:subscribe:after", (roomId) =>
|
|
793
|
+
this.onNewSubscription(roomId)
|
|
794
|
+
);
|
|
767
795
|
|
|
768
|
-
global.kuzzle.onCall(
|
|
769
|
-
|
|
770
|
-
|
|
796
|
+
global.kuzzle.onCall("core:realtime:unsubscribe:after", (roomId) =>
|
|
797
|
+
this.onUnsubscription(roomId)
|
|
798
|
+
);
|
|
771
799
|
|
|
772
|
-
global.kuzzle.on(
|
|
773
|
-
|
|
774
|
-
|
|
775
|
-
this.onDocumentNotification(rooms, notification);
|
|
776
|
-
});
|
|
800
|
+
global.kuzzle.on("core:notify:document", ({ notification, rooms }) => {
|
|
801
|
+
this.onDocumentNotification(rooms, notification);
|
|
802
|
+
});
|
|
777
803
|
|
|
778
|
-
global.kuzzle.on(
|
|
779
|
-
|
|
780
|
-
|
|
804
|
+
global.kuzzle.on("core:notify:user", ({ notification, room }) =>
|
|
805
|
+
this.onUserNotification(room, notification)
|
|
806
|
+
);
|
|
781
807
|
|
|
782
808
|
global.kuzzle.on(
|
|
783
|
-
|
|
809
|
+
"core:auth:strategyAdded",
|
|
784
810
|
({ name, pluginName, strategy }) => {
|
|
785
811
|
this.onAuthStrategyAdded(name, pluginName, strategy);
|
|
786
|
-
}
|
|
812
|
+
}
|
|
813
|
+
);
|
|
787
814
|
|
|
788
|
-
global.kuzzle.on(
|
|
789
|
-
|
|
790
|
-
|
|
815
|
+
global.kuzzle.on("core:auth:strategyRemoved", ({ name, pluginName }) =>
|
|
816
|
+
this.onAuthStrategyRemoved(name, pluginName)
|
|
817
|
+
);
|
|
791
818
|
|
|
792
|
-
global.kuzzle.on(
|
|
793
|
-
'admin:afterDump',
|
|
794
|
-
suffix => this.onDumpRequest(suffix));
|
|
819
|
+
global.kuzzle.on("admin:afterDump", (suffix) => this.onDumpRequest(suffix));
|
|
795
820
|
|
|
796
|
-
global.kuzzle.on(
|
|
797
|
-
'admin:afterResetSecurity',
|
|
798
|
-
() => this.onSecurityReset());
|
|
821
|
+
global.kuzzle.on("admin:afterResetSecurity", () => this.onSecurityReset());
|
|
799
822
|
|
|
800
|
-
global.kuzzle.on(
|
|
801
|
-
'admin:afterShutdown',
|
|
802
|
-
() => this.onShutdown());
|
|
823
|
+
global.kuzzle.on("admin:afterShutdown", () => this.onShutdown());
|
|
803
824
|
|
|
804
|
-
global.kuzzle.on(
|
|
805
|
-
|
|
806
|
-
|
|
825
|
+
global.kuzzle.on("collection:afterDeleteSpecifications", () =>
|
|
826
|
+
this.onValidatorsChanged()
|
|
827
|
+
);
|
|
807
828
|
|
|
808
|
-
global.kuzzle.on(
|
|
809
|
-
|
|
810
|
-
|
|
829
|
+
global.kuzzle.on("collection:afterUpdateSpecifications", () =>
|
|
830
|
+
this.onValidatorsChanged()
|
|
831
|
+
);
|
|
811
832
|
|
|
812
833
|
// Profile change events
|
|
813
|
-
global.kuzzle.on(
|
|
814
|
-
|
|
815
|
-
|
|
834
|
+
global.kuzzle.on("core:security:profile:create", ({ args: [profileId] }) =>
|
|
835
|
+
this.onProfileChanged(profileId)
|
|
836
|
+
);
|
|
816
837
|
|
|
817
838
|
global.kuzzle.on(
|
|
818
|
-
|
|
819
|
-
({ args: [
|
|
839
|
+
"core:security:profile:createOrReplace",
|
|
840
|
+
({ args: [profileId] }) => this.onProfileChanged(profileId)
|
|
841
|
+
);
|
|
820
842
|
|
|
821
|
-
global.kuzzle.on(
|
|
822
|
-
|
|
823
|
-
|
|
843
|
+
global.kuzzle.on("core:security:profile:update", ({ args: [profileId] }) =>
|
|
844
|
+
this.onProfileChanged(profileId)
|
|
845
|
+
);
|
|
824
846
|
|
|
825
|
-
global.kuzzle.on(
|
|
826
|
-
|
|
827
|
-
|
|
847
|
+
global.kuzzle.on("core:security:profile:delete", ({ args: [profileId] }) =>
|
|
848
|
+
this.onProfileChanged(profileId)
|
|
849
|
+
);
|
|
828
850
|
|
|
829
851
|
// Role change events
|
|
830
|
-
global.kuzzle.on(
|
|
831
|
-
|
|
832
|
-
|
|
852
|
+
global.kuzzle.on("core:security:role:create", ({ args: [roleId] }) =>
|
|
853
|
+
this.onRoleChanged(roleId)
|
|
854
|
+
);
|
|
833
855
|
|
|
834
856
|
global.kuzzle.on(
|
|
835
|
-
|
|
836
|
-
({ args: [
|
|
857
|
+
"core:security:role:createOrReplace",
|
|
858
|
+
({ args: [roleId] }) => this.onRoleChanged(roleId)
|
|
859
|
+
);
|
|
837
860
|
|
|
838
|
-
global.kuzzle.on(
|
|
839
|
-
|
|
840
|
-
|
|
861
|
+
global.kuzzle.on("core:security:role:update", ({ args: [roleId] }) =>
|
|
862
|
+
this.onRoleChanged(roleId)
|
|
863
|
+
);
|
|
841
864
|
|
|
842
|
-
global.kuzzle.on(
|
|
843
|
-
|
|
844
|
-
|
|
865
|
+
global.kuzzle.on("core:security:role:delete", ({ args: [roleId] }) =>
|
|
866
|
+
this.onRoleChanged(roleId)
|
|
867
|
+
);
|
|
845
868
|
|
|
846
869
|
// Index cache change events
|
|
847
|
-
global.kuzzle.on(
|
|
848
|
-
|
|
849
|
-
|
|
870
|
+
global.kuzzle.on("core:storage:index:create:after", ({ index, scope }) =>
|
|
871
|
+
this.onIndexAdded(scope, index)
|
|
872
|
+
);
|
|
850
873
|
|
|
851
|
-
global.kuzzle.on(
|
|
852
|
-
|
|
853
|
-
|
|
874
|
+
global.kuzzle.on("core:storage:index:delete:after", ({ index, scope }) =>
|
|
875
|
+
this.onIndexesRemoved(scope, [index])
|
|
876
|
+
);
|
|
854
877
|
|
|
855
|
-
global.kuzzle.on(
|
|
856
|
-
|
|
857
|
-
|
|
878
|
+
global.kuzzle.on("core:storage:index:mDelete:after", ({ indexes, scope }) =>
|
|
879
|
+
this.onIndexesRemoved(scope, indexes)
|
|
880
|
+
);
|
|
858
881
|
|
|
859
882
|
global.kuzzle.on(
|
|
860
|
-
|
|
883
|
+
"core:storage:collection:create:after",
|
|
861
884
|
({ collection, index, scope }) => {
|
|
862
885
|
this.onCollectionAdded(scope, index, collection);
|
|
863
|
-
}
|
|
886
|
+
}
|
|
887
|
+
);
|
|
864
888
|
|
|
865
889
|
global.kuzzle.on(
|
|
866
|
-
|
|
890
|
+
"core:storage:collection:delete:after",
|
|
867
891
|
({ collection, index, scope }) => {
|
|
868
892
|
this.onCollectionRemoved(scope, index, collection);
|
|
869
|
-
}
|
|
893
|
+
}
|
|
894
|
+
);
|
|
870
895
|
}
|
|
871
896
|
|
|
872
897
|
/**
|
|
@@ -875,14 +900,15 @@ class ClusterNode {
|
|
|
875
900
|
* @param {NormalizedFilter} payload
|
|
876
901
|
* @return {void}
|
|
877
902
|
*/
|
|
878
|
-
onNewRealtimeRoom
|
|
903
|
+
onNewRealtimeRoom(payload) {
|
|
879
904
|
const roomMessageId = this.publisher.sendNewRealtimeRoom(payload);
|
|
880
905
|
|
|
881
906
|
debug(
|
|
882
|
-
|
|
907
|
+
"[%s] Broadcasting new realtime room %s (message: %d)",
|
|
883
908
|
this.nodeId,
|
|
884
909
|
payload.id,
|
|
885
|
-
roomMessageId
|
|
910
|
+
roomMessageId
|
|
911
|
+
);
|
|
886
912
|
|
|
887
913
|
const icpair = fromKoncordeIndex(payload.index);
|
|
888
914
|
|
|
@@ -895,7 +921,8 @@ class ClusterNode {
|
|
|
895
921
|
messageId: roomMessageId,
|
|
896
922
|
nodeId: this.nodeId,
|
|
897
923
|
subscribers: 0,
|
|
898
|
-
}
|
|
924
|
+
}
|
|
925
|
+
);
|
|
899
926
|
}
|
|
900
927
|
|
|
901
928
|
/**
|
|
@@ -904,14 +931,15 @@ class ClusterNode {
|
|
|
904
931
|
* @param {string} roomId
|
|
905
932
|
* @return {void}
|
|
906
933
|
*/
|
|
907
|
-
onNewSubscription
|
|
934
|
+
onNewSubscription(roomId) {
|
|
908
935
|
const subMessageId = this.publisher.sendSubscription(roomId);
|
|
909
936
|
|
|
910
937
|
debug(
|
|
911
|
-
|
|
938
|
+
"[%s] Broadcasting new realtime subscription on room %s (message: %d)",
|
|
912
939
|
this.nodeId,
|
|
913
940
|
roomId,
|
|
914
|
-
subMessageId
|
|
941
|
+
subMessageId
|
|
942
|
+
);
|
|
915
943
|
|
|
916
944
|
this.fullState.addRealtimeSubscription(roomId, this.nodeId, subMessageId);
|
|
917
945
|
}
|
|
@@ -922,15 +950,16 @@ class ClusterNode {
|
|
|
922
950
|
* @param {string} roomId
|
|
923
951
|
* @return {void}
|
|
924
952
|
*/
|
|
925
|
-
removeRealtimeRoom
|
|
953
|
+
removeRealtimeRoom(roomId) {
|
|
926
954
|
const messageId = this.publisher.sendRemoveRealtimeRoom(roomId);
|
|
927
|
-
|
|
955
|
+
|
|
928
956
|
debug(
|
|
929
|
-
|
|
957
|
+
"[%s] Broadcasted the removal of room %s (message: %d)",
|
|
930
958
|
this.nodeId,
|
|
931
959
|
roomId,
|
|
932
|
-
messageId
|
|
933
|
-
|
|
960
|
+
messageId
|
|
961
|
+
);
|
|
962
|
+
|
|
934
963
|
this.fullState.removeRealtimeRoom(roomId, this.nodeId);
|
|
935
964
|
}
|
|
936
965
|
|
|
@@ -940,14 +969,15 @@ class ClusterNode {
|
|
|
940
969
|
* @param {string} event name
|
|
941
970
|
* @param {Object} payload - event payload
|
|
942
971
|
*/
|
|
943
|
-
broadcast
|
|
972
|
+
broadcast(event, payload) {
|
|
944
973
|
const messageId = this.publisher.sendClusterWideEvent(event, payload);
|
|
945
974
|
|
|
946
975
|
debug(
|
|
947
976
|
'[%s] Emitted cluster-wide event "%s" (message: %d)',
|
|
948
977
|
this.nodeId,
|
|
949
978
|
event,
|
|
950
|
-
messageId
|
|
979
|
+
messageId
|
|
980
|
+
);
|
|
951
981
|
}
|
|
952
982
|
|
|
953
983
|
/**
|
|
@@ -956,14 +986,15 @@ class ClusterNode {
|
|
|
956
986
|
* @param {string} roomId
|
|
957
987
|
* @return {void}
|
|
958
988
|
*/
|
|
959
|
-
onUnsubscription
|
|
989
|
+
onUnsubscription(roomId) {
|
|
960
990
|
const messageId = this.publisher.sendUnsubscription(roomId);
|
|
961
991
|
|
|
962
992
|
debug(
|
|
963
|
-
|
|
993
|
+
"[%s] Broadcasting realtime unsubscription on room %s (message: %d)",
|
|
964
994
|
this.nodeId,
|
|
965
995
|
roomId,
|
|
966
|
-
messageId
|
|
996
|
+
messageId
|
|
997
|
+
);
|
|
967
998
|
|
|
968
999
|
this.fullState.removeRealtimeSubscription(roomId, this.nodeId, messageId);
|
|
969
1000
|
}
|
|
@@ -975,7 +1006,7 @@ class ClusterNode {
|
|
|
975
1006
|
* @param {DocumentNotification} notification
|
|
976
1007
|
* @return {void}
|
|
977
1008
|
*/
|
|
978
|
-
onDocumentNotification
|
|
1009
|
+
onDocumentNotification(rooms, notification) {
|
|
979
1010
|
this.publisher.sendDocumentNotification(rooms, notification);
|
|
980
1011
|
}
|
|
981
1012
|
|
|
@@ -986,7 +1017,7 @@ class ClusterNode {
|
|
|
986
1017
|
* @param {UserNotification} notification
|
|
987
1018
|
* @return {void}
|
|
988
1019
|
*/
|
|
989
|
-
onUserNotification
|
|
1020
|
+
onUserNotification(room, notification) {
|
|
990
1021
|
this.publisher.sendUserNotification(room, notification);
|
|
991
1022
|
}
|
|
992
1023
|
|
|
@@ -998,11 +1029,12 @@ class ClusterNode {
|
|
|
998
1029
|
* @param {Object} strategyObject
|
|
999
1030
|
* @return {void}
|
|
1000
1031
|
*/
|
|
1001
|
-
onAuthStrategyAdded
|
|
1032
|
+
onAuthStrategyAdded(strategyName, pluginName, strategyObject) {
|
|
1002
1033
|
this.publisher.sendNewAuthStrategy(
|
|
1003
1034
|
strategyName,
|
|
1004
1035
|
pluginName,
|
|
1005
|
-
strategyObject
|
|
1036
|
+
strategyObject
|
|
1037
|
+
);
|
|
1006
1038
|
|
|
1007
1039
|
this.fullState.addAuthStrategy({
|
|
1008
1040
|
pluginName,
|
|
@@ -1018,7 +1050,7 @@ class ClusterNode {
|
|
|
1018
1050
|
* @param {string} pluginName
|
|
1019
1051
|
* @return {void}
|
|
1020
1052
|
*/
|
|
1021
|
-
onAuthStrategyRemoved
|
|
1053
|
+
onAuthStrategyRemoved(strategyName, pluginName) {
|
|
1022
1054
|
this.publisher.sendRemoveAuthStrategy(strategyName, pluginName);
|
|
1023
1055
|
|
|
1024
1056
|
this.fullState.removeAuthStrategy(strategyName);
|
|
@@ -1030,7 +1062,7 @@ class ClusterNode {
|
|
|
1030
1062
|
* @param {string} suffix
|
|
1031
1063
|
* @return {void}
|
|
1032
1064
|
*/
|
|
1033
|
-
onDumpRequest
|
|
1065
|
+
onDumpRequest(suffix) {
|
|
1034
1066
|
this.publisher.sendDumpRequest(suffix);
|
|
1035
1067
|
}
|
|
1036
1068
|
|
|
@@ -1039,8 +1071,8 @@ class ClusterNode {
|
|
|
1039
1071
|
*
|
|
1040
1072
|
* @return {void}
|
|
1041
1073
|
*/
|
|
1042
|
-
onSecurityReset
|
|
1043
|
-
this.publisher.send(
|
|
1074
|
+
onSecurityReset() {
|
|
1075
|
+
this.publisher.send("ResetSecurity", {});
|
|
1044
1076
|
}
|
|
1045
1077
|
|
|
1046
1078
|
/**
|
|
@@ -1048,8 +1080,8 @@ class ClusterNode {
|
|
|
1048
1080
|
*
|
|
1049
1081
|
* @return {void}
|
|
1050
1082
|
*/
|
|
1051
|
-
onValidatorsChanged
|
|
1052
|
-
this.publisher.send(
|
|
1083
|
+
onValidatorsChanged() {
|
|
1084
|
+
this.publisher.send("RefreshValidators", {});
|
|
1053
1085
|
}
|
|
1054
1086
|
|
|
1055
1087
|
/**
|
|
@@ -1058,8 +1090,8 @@ class ClusterNode {
|
|
|
1058
1090
|
* @param {string} profileId
|
|
1059
1091
|
* @return {void}
|
|
1060
1092
|
*/
|
|
1061
|
-
onProfileChanged
|
|
1062
|
-
this.publisher.send(
|
|
1093
|
+
onProfileChanged(profileId) {
|
|
1094
|
+
this.publisher.send("InvalidateProfile", { profileId });
|
|
1063
1095
|
}
|
|
1064
1096
|
|
|
1065
1097
|
/**
|
|
@@ -1068,8 +1100,8 @@ class ClusterNode {
|
|
|
1068
1100
|
* @param {string} roleId
|
|
1069
1101
|
* @return {void}
|
|
1070
1102
|
*/
|
|
1071
|
-
onRoleChanged
|
|
1072
|
-
this.publisher.send(
|
|
1103
|
+
onRoleChanged(roleId) {
|
|
1104
|
+
this.publisher.send("InvalidateRole", { roleId });
|
|
1073
1105
|
}
|
|
1074
1106
|
|
|
1075
1107
|
/**
|
|
@@ -1079,7 +1111,7 @@ class ClusterNode {
|
|
|
1079
1111
|
* @param {string} index
|
|
1080
1112
|
* @return {void}
|
|
1081
1113
|
*/
|
|
1082
|
-
onIndexAdded
|
|
1114
|
+
onIndexAdded(scope, index) {
|
|
1083
1115
|
this.publisher.sendAddIndex(scope, index);
|
|
1084
1116
|
}
|
|
1085
1117
|
|
|
@@ -1091,7 +1123,7 @@ class ClusterNode {
|
|
|
1091
1123
|
* @param {string} collection
|
|
1092
1124
|
* @return {void}
|
|
1093
1125
|
*/
|
|
1094
|
-
onCollectionAdded
|
|
1126
|
+
onCollectionAdded(scope, index, collection) {
|
|
1095
1127
|
this.publisher.sendAddCollection(scope, index, collection);
|
|
1096
1128
|
}
|
|
1097
1129
|
|
|
@@ -1102,7 +1134,7 @@ class ClusterNode {
|
|
|
1102
1134
|
* @param {Array.<string>} indexes
|
|
1103
1135
|
* @return {void}
|
|
1104
1136
|
*/
|
|
1105
|
-
onIndexesRemoved
|
|
1137
|
+
onIndexesRemoved(scope, indexes) {
|
|
1106
1138
|
this.publisher.sendRemoveIndexes(scope, indexes);
|
|
1107
1139
|
}
|
|
1108
1140
|
|
|
@@ -1114,7 +1146,7 @@ class ClusterNode {
|
|
|
1114
1146
|
* @param {string} collection
|
|
1115
1147
|
* @return {void}
|
|
1116
1148
|
*/
|
|
1117
|
-
onCollectionRemoved
|
|
1149
|
+
onCollectionRemoved(scope, index, collection) {
|
|
1118
1150
|
this.publisher.sendRemoveCollection(scope, index, collection);
|
|
1119
1151
|
}
|
|
1120
1152
|
|
|
@@ -1123,15 +1155,15 @@ class ClusterNode {
|
|
|
1123
1155
|
*
|
|
1124
1156
|
* @return {void}
|
|
1125
1157
|
*/
|
|
1126
|
-
onShutdown
|
|
1127
|
-
this.publisher.send(
|
|
1158
|
+
onShutdown() {
|
|
1159
|
+
this.publisher.send("Shutdown", {});
|
|
1128
1160
|
}
|
|
1129
1161
|
|
|
1130
1162
|
/**
|
|
1131
1163
|
* Triggered when the index cache has been manually refreshed
|
|
1132
1164
|
*/
|
|
1133
|
-
onIndexCacheRefreshed
|
|
1134
|
-
this.publisher.send(
|
|
1165
|
+
onIndexCacheRefreshed() {
|
|
1166
|
+
this.publisher.send("RefreshIndexCache", {});
|
|
1135
1167
|
}
|
|
1136
1168
|
|
|
1137
1169
|
/**
|
|
@@ -1140,12 +1172,12 @@ class ClusterNode {
|
|
|
1140
1172
|
*
|
|
1141
1173
|
* @param {string} roomId
|
|
1142
1174
|
* @return {void}
|
|
1143
|
-
|
|
1144
|
-
async countRealtimeSubscribers
|
|
1175
|
+
*/
|
|
1176
|
+
async countRealtimeSubscribers(roomId) {
|
|
1145
1177
|
return this.fullState.countRealtimeSubscriptions(roomId);
|
|
1146
1178
|
}
|
|
1147
1179
|
|
|
1148
|
-
shutdownNode
|
|
1180
|
+
shutdownNode() {
|
|
1149
1181
|
global.kuzzle.log.error(JSON.stringify(this.fullState.serialize()));
|
|
1150
1182
|
global.kuzzle.shutdown();
|
|
1151
1183
|
}
|