@splitsoftware/splitio-commons 3.1.1-rc.1 → 3.1.1-rc.10
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/CHANGES.txt +10 -1
- package/cjs/evaluator/condition/index.js +2 -2
- package/cjs/evaluator/fallbackTreatmentsCalculator/fallbackSanitizer/index.js +8 -5
- package/cjs/evaluator/index.js +71 -76
- package/cjs/listeners/browser.js +1 -2
- package/cjs/listeners/node.js +4 -4
- package/cjs/logger/constants.js +20 -15
- package/cjs/logger/messages/debug.js +6 -5
- package/cjs/logger/messages/error.js +3 -3
- package/cjs/logger/messages/info.js +4 -3
- package/cjs/logger/messages/warn.js +7 -6
- package/cjs/presets/serverSide.js +2 -2
- package/cjs/readiness/constants.js +4 -5
- package/cjs/readiness/readinessManager.js +23 -23
- package/cjs/readiness/sdkReadinessManager.js +17 -1
- package/cjs/sdkClient/client.js +51 -27
- package/cjs/sdkClient/clientInputValidation.js +17 -6
- package/cjs/sdkClient/sdkClient.js +60 -3
- package/cjs/sdkFactory/index.js +15 -11
- package/cjs/sdkManager/index.js +5 -5
- package/cjs/services/decorateHeaders.js +1 -2
- package/cjs/services/splitApi.js +1 -14
- package/cjs/services/splitHttpClient.js +5 -3
- package/cjs/storages/AbstractSplitsCacheAsync.js +51 -0
- package/cjs/storages/AbstractSplitsCacheSync.js +76 -0
- package/cjs/storages/KeyBuilder.js +6 -6
- package/cjs/storages/KeyBuilderCS.js +5 -5
- package/cjs/storages/KeyBuilderSS.js +2 -2
- package/cjs/storages/getRolloutPlan.js +3 -3
- package/cjs/storages/inLocalStorage/MySegmentsCacheInLocal.js +2 -1
- package/cjs/storages/inLocalStorage/RBSegmentsCacheInLocal.js +10 -10
- package/cjs/storages/inLocalStorage/SplitsCacheInLocal.js +194 -0
- package/cjs/storages/inLocalStorage/index.js +6 -6
- package/cjs/storages/inLocalStorage/validateCache.js +3 -3
- package/cjs/storages/inMemory/InMemoryStorage.js +4 -4
- package/cjs/storages/inMemory/InMemoryStorageCS.js +5 -5
- package/cjs/storages/inMemory/RBSegmentsCacheInMemory.js +5 -5
- package/cjs/storages/inMemory/SegmentsCacheInMemory.js +1 -1
- package/cjs/storages/inMemory/SplitsCacheInMemory.js +121 -0
- package/cjs/storages/inMemory/TelemetryCacheInMemory.js +5 -5
- package/cjs/storages/inRedis/RBSegmentsCacheInRedis.js +1 -1
- package/cjs/storages/inRedis/RedisAdapter.js +8 -5
- package/cjs/storages/inRedis/{DefinitionsCacheInRedis.js → SplitsCacheInRedis.js} +77 -77
- package/cjs/storages/inRedis/index.js +2 -2
- package/cjs/storages/pluggable/RBSegmentsCachePluggable.js +1 -1
- package/cjs/storages/pluggable/SplitsCachePluggable.js +212 -0
- package/cjs/storages/pluggable/index.js +2 -2
- package/cjs/storages/setRolloutPlan.js +4 -4
- package/cjs/storages/utils.js +0 -1
- package/cjs/sync/offline/syncTasks/fromObjectSyncTask.js +5 -5
- package/cjs/sync/polling/fetchers/splitChangesFetcher.js +15 -24
- package/cjs/sync/polling/pollingManagerCS.js +20 -20
- package/cjs/sync/polling/pollingManagerSS.js +15 -15
- package/cjs/sync/polling/syncTasks/segmentsSyncTask.js +3 -2
- package/cjs/sync/polling/syncTasks/splitsSyncTask.js +13 -0
- package/cjs/sync/polling/updaters/mySegmentsUpdater.js +3 -3
- package/cjs/sync/polling/updaters/segmentChangesUpdater.js +6 -6
- package/cjs/sync/polling/updaters/{definitionChangesUpdater.js → splitChangesUpdater.js} +68 -65
- package/cjs/sync/streaming/AuthClient/index.js +1 -1
- package/cjs/sync/streaming/SSEHandler/NotificationKeeper.js +1 -1
- package/cjs/sync/streaming/SSEHandler/index.js +1 -1
- package/cjs/sync/streaming/UpdateWorkers/{DefinitionsUpdateWorker.js → SplitsUpdateWorker.js} +19 -16
- package/cjs/sync/streaming/constants.js +3 -3
- package/cjs/sync/streaming/parseUtils.js +11 -11
- package/cjs/sync/streaming/pushManager.js +16 -16
- package/cjs/sync/submitters/eventsSubmitter.js +1 -1
- package/cjs/sync/submitters/impressionCountsSubmitter.js +1 -1
- package/cjs/sync/submitters/impressionsSubmitter.js +4 -5
- package/cjs/sync/submitters/telemetrySubmitter.js +4 -3
- package/cjs/sync/submitters/uniqueKeysSubmitter.js +1 -1
- package/cjs/sync/syncManagerOnline.js +7 -12
- package/cjs/utils/Backoff.js +0 -20
- package/cjs/utils/inputValidation/index.js +7 -7
- package/cjs/utils/inputValidation/isOperational.js +4 -4
- package/cjs/utils/inputValidation/{definition.js → split.js} +10 -10
- package/cjs/utils/inputValidation/{definitionExistence.js → splitExistence.js} +6 -6
- package/cjs/utils/inputValidation/splits.js +25 -0
- package/cjs/utils/labels/index.js +3 -3
- package/cjs/utils/settingsValidation/index.js +0 -2
- package/cjs/utils/settingsValidation/splitFilters.js +3 -3
- package/cjs/utils/settingsValidation/url.js +2 -6
- package/esm/evaluator/condition/index.js +2 -2
- package/esm/evaluator/fallbackTreatmentsCalculator/fallbackSanitizer/index.js +8 -5
- package/esm/evaluator/index.js +71 -75
- package/esm/listeners/browser.js +1 -2
- package/esm/listeners/node.js +4 -4
- package/esm/logger/constants.js +17 -12
- package/esm/logger/messages/debug.js +6 -5
- package/esm/logger/messages/error.js +3 -3
- package/esm/logger/messages/info.js +4 -3
- package/esm/logger/messages/warn.js +7 -6
- package/esm/presets/serverSide.js +2 -2
- package/esm/readiness/constants.js +3 -4
- package/esm/readiness/readinessManager.js +24 -24
- package/esm/readiness/sdkReadinessManager.js +18 -2
- package/esm/sdkClient/client.js +51 -26
- package/esm/sdkClient/clientInputValidation.js +19 -8
- package/esm/sdkClient/sdkClient.js +60 -3
- package/esm/sdkFactory/index.js +16 -12
- package/esm/sdkManager/index.js +6 -6
- package/esm/services/decorateHeaders.js +1 -2
- package/esm/services/splitApi.js +1 -14
- package/esm/services/splitHttpClient.js +5 -3
- package/esm/storages/AbstractSplitsCacheAsync.js +48 -0
- package/esm/storages/AbstractSplitsCacheSync.js +71 -0
- package/esm/storages/KeyBuilder.js +6 -6
- package/esm/storages/KeyBuilderCS.js +5 -5
- package/esm/storages/KeyBuilderSS.js +2 -2
- package/esm/storages/getRolloutPlan.js +3 -3
- package/esm/storages/inLocalStorage/MySegmentsCacheInLocal.js +2 -1
- package/esm/storages/inLocalStorage/RBSegmentsCacheInLocal.js +7 -7
- package/esm/storages/inLocalStorage/SplitsCacheInLocal.js +191 -0
- package/esm/storages/inLocalStorage/index.js +6 -6
- package/esm/storages/inLocalStorage/validateCache.js +3 -3
- package/esm/storages/inMemory/InMemoryStorage.js +4 -4
- package/esm/storages/inMemory/InMemoryStorageCS.js +5 -5
- package/esm/storages/inMemory/RBSegmentsCacheInMemory.js +2 -2
- package/esm/storages/inMemory/SegmentsCacheInMemory.js +1 -1
- package/esm/storages/inMemory/SplitsCacheInMemory.js +118 -0
- package/esm/storages/inMemory/TelemetryCacheInMemory.js +5 -5
- package/esm/storages/inRedis/RBSegmentsCacheInRedis.js +1 -1
- package/esm/storages/inRedis/RedisAdapter.js +8 -5
- package/esm/storages/inRedis/{DefinitionsCacheInRedis.js → SplitsCacheInRedis.js} +76 -76
- package/esm/storages/inRedis/index.js +2 -2
- package/esm/storages/pluggable/RBSegmentsCachePluggable.js +1 -1
- package/esm/storages/pluggable/SplitsCachePluggable.js +209 -0
- package/esm/storages/pluggable/index.js +2 -2
- package/esm/storages/setRolloutPlan.js +4 -4
- package/esm/storages/utils.js +0 -1
- package/esm/sync/offline/syncTasks/fromObjectSyncTask.js +6 -6
- package/esm/sync/polling/fetchers/splitChangesFetcher.js +16 -25
- package/esm/sync/polling/pollingManagerCS.js +17 -17
- package/esm/sync/polling/pollingManagerSS.js +15 -15
- package/esm/sync/polling/syncTasks/segmentsSyncTask.js +3 -2
- package/esm/sync/polling/syncTasks/splitsSyncTask.js +9 -0
- package/esm/sync/polling/updaters/mySegmentsUpdater.js +3 -3
- package/esm/sync/polling/updaters/segmentChangesUpdater.js +7 -7
- package/esm/sync/polling/updaters/{definitionChangesUpdater.js → splitChangesUpdater.js} +68 -65
- package/esm/sync/streaming/AuthClient/index.js +1 -1
- package/esm/sync/streaming/SSEHandler/NotificationKeeper.js +2 -2
- package/esm/sync/streaming/SSEHandler/index.js +2 -2
- package/esm/sync/streaming/UpdateWorkers/{DefinitionsUpdateWorker.js → SplitsUpdateWorker.js} +18 -15
- package/esm/sync/streaming/constants.js +2 -2
- package/esm/sync/streaming/parseUtils.js +9 -9
- package/esm/sync/streaming/pushManager.js +18 -18
- package/esm/sync/submitters/eventsSubmitter.js +1 -1
- package/esm/sync/submitters/impressionCountsSubmitter.js +1 -1
- package/esm/sync/submitters/impressionsSubmitter.js +4 -5
- package/esm/sync/submitters/telemetrySubmitter.js +4 -3
- package/esm/sync/submitters/uniqueKeysSubmitter.js +1 -1
- package/esm/sync/syncManagerOnline.js +6 -11
- package/esm/utils/Backoff.js +0 -20
- package/esm/utils/inputValidation/index.js +3 -3
- package/esm/utils/inputValidation/isOperational.js +4 -4
- package/esm/utils/inputValidation/{definition.js → split.js} +8 -8
- package/esm/utils/inputValidation/splitExistence.js +15 -0
- package/esm/utils/inputValidation/splits.js +21 -0
- package/esm/utils/labels/index.js +2 -2
- package/esm/utils/settingsValidation/index.js +0 -2
- package/esm/utils/settingsValidation/splitFilters.js +3 -3
- package/esm/utils/settingsValidation/url.js +2 -6
- package/package.json +6 -7
- package/src/dtos/types.ts +1 -1
- package/src/evaluator/index.ts +11 -5
- package/src/evaluator/types.ts +1 -0
- package/src/presets/serverSide.ts +3 -3
- package/src/sdkClient/client.ts +3 -4
- package/src/sdkClient/sdkLifecycle.ts +3 -0
- package/src/services/authProvider.ts +41 -19
- package/src/services/secureSplitHttpClient.ts +10 -18
- package/src/services/serviceApi.ts +27 -24
- package/src/services/splitApi.ts +10 -9
- package/src/services/types.ts +5 -4
- package/src/storages/inRedis/RedisAdapter.ts +8 -5
- package/src/sync/polling/pollingManagerCS.ts +80 -78
- package/src/sync/polling/pollingManagerSS.ts +49 -45
- package/src/sync/polling/updaters/definitionChangesUpdater.ts +3 -3
- package/src/sync/polling/updaters/segmentChangesUpdater.ts +1 -1
- package/src/sync/streaming/AuthClient/index.ts +14 -15
- package/src/sync/streaming/AuthClient/types.ts +9 -13
- package/src/sync/streaming/SSEClient/index.ts +2 -2
- package/src/sync/streaming/SSEClient/types.ts +2 -2
- package/src/sync/streaming/SSEHandler/index.ts +2 -1
- package/src/sync/streaming/SSEHandler/types.ts +2 -2
- package/src/sync/streaming/constants.ts +1 -0
- package/src/sync/streaming/pushManager.ts +32 -42
- package/src/sync/streaming/types.ts +3 -2
- package/src/sync/submitters/impressionsSubmitter.ts +3 -3
- package/src/sync/submitters/types.ts +2 -2
- package/src/sync/syncManagerOnline.ts +2 -8
- package/src/utils/Backoff.ts +16 -4
- package/types/splitio.d.ts +5 -4
- package/cjs/platform/browser.js +0 -15
- package/cjs/platform/getEventSource/browser.js +0 -8
- package/cjs/platform/getEventSource/eventsource.js +0 -480
- package/cjs/platform/getEventSource/node.js +0 -26
- package/cjs/platform/getFetch/browser.js +0 -9
- package/cjs/platform/getFetch/node.js +0 -27
- package/cjs/platform/getOptions/node.js +0 -25
- package/cjs/platform/node.js +0 -17
- package/cjs/sdkClient/sdkLifecycle.js +0 -72
- package/cjs/sdkClient/trackMethod.js +0 -56
- package/cjs/services/authProvider.js +0 -67
- package/cjs/services/secureSplitHttpClient.js +0 -39
- package/cjs/services/serviceApi.js +0 -145
- package/cjs/storages/AbstractDefinitionsCacheAsync.js +0 -51
- package/cjs/storages/AbstractDefinitionsCacheSync.js +0 -76
- package/cjs/storages/inLocalStorage/DefinitionsCacheInLocal.js +0 -194
- package/cjs/storages/inMemory/DefinitionsCacheInMemory.js +0 -121
- package/cjs/storages/pluggable/DefinitionsCachePluggable.js +0 -212
- package/cjs/sync/polling/syncTasks/definitionsSyncTask.js +0 -13
- package/cjs/utils/EventEmitter.js +0 -391
- package/cjs/utils/filter/bloomFilter.js +0 -37
- package/cjs/utils/inputValidation/definitions.js +0 -25
- package/cjs/utils/inputValidation/target.js +0 -22
- package/esm/platform/browser.js +0 -12
- package/esm/platform/getEventSource/browser.js +0 -4
- package/esm/platform/getEventSource/eventsource.js +0 -480
- package/esm/platform/getEventSource/node.js +0 -20
- package/esm/platform/getFetch/browser.js +0 -5
- package/esm/platform/getFetch/node.js +0 -22
- package/esm/platform/getOptions/node.js +0 -20
- package/esm/platform/node.js +0 -14
- package/esm/sdkClient/sdkLifecycle.js +0 -68
- package/esm/sdkClient/trackMethod.js +0 -52
- package/esm/services/authProvider.js +0 -63
- package/esm/services/secureSplitHttpClient.js +0 -35
- package/esm/services/serviceApi.js +0 -141
- package/esm/storages/AbstractDefinitionsCacheAsync.js +0 -48
- package/esm/storages/AbstractDefinitionsCacheSync.js +0 -71
- package/esm/storages/inLocalStorage/DefinitionsCacheInLocal.js +0 -191
- package/esm/storages/inMemory/DefinitionsCacheInMemory.js +0 -118
- package/esm/storages/pluggable/DefinitionsCachePluggable.js +0 -209
- package/esm/sync/polling/syncTasks/definitionsSyncTask.js +0 -9
- package/esm/utils/EventEmitter.js +0 -387
- package/esm/utils/filter/bloomFilter.js +0 -33
- package/esm/utils/inputValidation/definitionExistence.js +0 -15
- package/esm/utils/inputValidation/definitions.js +0 -21
- package/esm/utils/inputValidation/target.js +0 -18
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.RBSegmentsCacheInMemory = void 0;
|
|
4
4
|
var sets_1 = require("../../utils/lang/sets");
|
|
5
|
-
var
|
|
5
|
+
var AbstractSplitsCacheSync_1 = require("../AbstractSplitsCacheSync");
|
|
6
6
|
var RBSegmentsCacheInMemory = /** @class */ (function () {
|
|
7
7
|
function RBSegmentsCacheInMemory() {
|
|
8
8
|
this.cache = {};
|
|
@@ -17,17 +17,17 @@ var RBSegmentsCacheInMemory = /** @class */ (function () {
|
|
|
17
17
|
RBSegmentsCacheInMemory.prototype.update = function (toAdd, toRemove, changeNumber) {
|
|
18
18
|
var _this = this;
|
|
19
19
|
var updated = toAdd.map(function (toAdd) { return _this.add(toAdd); }).some(function (result) { return result; });
|
|
20
|
-
updated = toRemove.map(function (toRemove) { return _this.remove(toRemove); }).some(function (result) { return result; }) || updated;
|
|
20
|
+
updated = toRemove.map(function (toRemove) { return _this.remove(toRemove.name); }).some(function (result) { return result; }) || updated;
|
|
21
21
|
this.changeNumber = changeNumber;
|
|
22
22
|
return updated;
|
|
23
23
|
};
|
|
24
24
|
RBSegmentsCacheInMemory.prototype.add = function (rbSegment) {
|
|
25
25
|
var name = rbSegment.name;
|
|
26
26
|
var previous = this.get(name);
|
|
27
|
-
if (previous && (0,
|
|
27
|
+
if (previous && (0, AbstractSplitsCacheSync_1.usesSegments)(previous))
|
|
28
28
|
this.segmentsCount--;
|
|
29
29
|
this.cache[name] = rbSegment;
|
|
30
|
-
if ((0,
|
|
30
|
+
if ((0, AbstractSplitsCacheSync_1.usesSegments)(rbSegment))
|
|
31
31
|
this.segmentsCount++;
|
|
32
32
|
return true;
|
|
33
33
|
};
|
|
@@ -36,7 +36,7 @@ var RBSegmentsCacheInMemory = /** @class */ (function () {
|
|
|
36
36
|
if (!rbSegment)
|
|
37
37
|
return false;
|
|
38
38
|
delete this.cache[name];
|
|
39
|
-
if ((0,
|
|
39
|
+
if ((0, AbstractSplitsCacheSync_1.usesSegments)(rbSegment))
|
|
40
40
|
this.segmentsCount--;
|
|
41
41
|
return true;
|
|
42
42
|
};
|
|
@@ -3,7 +3,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.SegmentsCacheInMemory = void 0;
|
|
4
4
|
var lang_1 = require("../../utils/lang");
|
|
5
5
|
/**
|
|
6
|
-
* Default
|
|
6
|
+
* Default ISplitsCacheSync implementation for server-side that stores segments definitions in memory.
|
|
7
7
|
*/
|
|
8
8
|
var SegmentsCacheInMemory = /** @class */ (function () {
|
|
9
9
|
function SegmentsCacheInMemory() {
|
|
@@ -0,0 +1,121 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.SplitsCacheInMemory = void 0;
|
|
4
|
+
var tslib_1 = require("tslib");
|
|
5
|
+
var AbstractSplitsCacheSync_1 = require("../AbstractSplitsCacheSync");
|
|
6
|
+
var lang_1 = require("../../utils/lang");
|
|
7
|
+
/**
|
|
8
|
+
* Default ISplitsCacheSync implementation that stores split definitions in memory.
|
|
9
|
+
*/
|
|
10
|
+
var SplitsCacheInMemory = /** @class */ (function (_super) {
|
|
11
|
+
tslib_1.__extends(SplitsCacheInMemory, _super);
|
|
12
|
+
function SplitsCacheInMemory(splitFiltersValidation) {
|
|
13
|
+
var _this = _super.call(this) || this;
|
|
14
|
+
_this.splitsCache = {};
|
|
15
|
+
_this.ttCache = {};
|
|
16
|
+
_this.changeNumber = -1;
|
|
17
|
+
_this.segmentsCount = 0;
|
|
18
|
+
_this.flagSetsCache = {};
|
|
19
|
+
_this.flagSetsFilter = splitFiltersValidation ? splitFiltersValidation.groupedFilters.bySet : [];
|
|
20
|
+
return _this;
|
|
21
|
+
}
|
|
22
|
+
SplitsCacheInMemory.prototype.clear = function () {
|
|
23
|
+
this.splitsCache = {};
|
|
24
|
+
this.ttCache = {};
|
|
25
|
+
this.changeNumber = -1;
|
|
26
|
+
this.segmentsCount = 0;
|
|
27
|
+
this.flagSetsCache = {};
|
|
28
|
+
};
|
|
29
|
+
SplitsCacheInMemory.prototype.addSplit = function (split) {
|
|
30
|
+
var name = split.name;
|
|
31
|
+
var previousSplit = this.getSplit(name);
|
|
32
|
+
if (previousSplit) { // We had this Split already
|
|
33
|
+
var previousTtName = previousSplit.trafficTypeName;
|
|
34
|
+
this.ttCache[previousTtName]--;
|
|
35
|
+
if (!this.ttCache[previousTtName])
|
|
36
|
+
delete this.ttCache[previousTtName];
|
|
37
|
+
this.removeFromFlagSets(previousSplit.name, previousSplit.sets);
|
|
38
|
+
// Subtract from segments count for the previous version of this Split
|
|
39
|
+
if ((0, AbstractSplitsCacheSync_1.usesSegments)(previousSplit))
|
|
40
|
+
this.segmentsCount--;
|
|
41
|
+
}
|
|
42
|
+
// Store the Split.
|
|
43
|
+
this.splitsCache[name] = split;
|
|
44
|
+
// Update TT cache
|
|
45
|
+
var ttName = split.trafficTypeName;
|
|
46
|
+
this.ttCache[ttName] = (this.ttCache[ttName] || 0) + 1;
|
|
47
|
+
this.addToFlagSets(split);
|
|
48
|
+
// Add to segments count for the new version of the Split
|
|
49
|
+
if ((0, AbstractSplitsCacheSync_1.usesSegments)(split))
|
|
50
|
+
this.segmentsCount++;
|
|
51
|
+
return true;
|
|
52
|
+
};
|
|
53
|
+
SplitsCacheInMemory.prototype.removeSplit = function (name) {
|
|
54
|
+
var split = this.getSplit(name);
|
|
55
|
+
if (!split)
|
|
56
|
+
return false;
|
|
57
|
+
// Delete the Split
|
|
58
|
+
delete this.splitsCache[name];
|
|
59
|
+
var ttName = split.trafficTypeName;
|
|
60
|
+
this.ttCache[ttName]--; // Update tt cache
|
|
61
|
+
if (!this.ttCache[ttName])
|
|
62
|
+
delete this.ttCache[ttName];
|
|
63
|
+
this.removeFromFlagSets(split.name, split.sets);
|
|
64
|
+
// Update the segments count.
|
|
65
|
+
if ((0, AbstractSplitsCacheSync_1.usesSegments)(split))
|
|
66
|
+
this.segmentsCount--;
|
|
67
|
+
return true;
|
|
68
|
+
};
|
|
69
|
+
SplitsCacheInMemory.prototype.getSplit = function (name) {
|
|
70
|
+
return this.splitsCache[name] || null;
|
|
71
|
+
};
|
|
72
|
+
SplitsCacheInMemory.prototype.setChangeNumber = function (changeNumber) {
|
|
73
|
+
this.changeNumber = changeNumber;
|
|
74
|
+
return true;
|
|
75
|
+
};
|
|
76
|
+
SplitsCacheInMemory.prototype.getChangeNumber = function () {
|
|
77
|
+
return this.changeNumber;
|
|
78
|
+
};
|
|
79
|
+
SplitsCacheInMemory.prototype.getSplitNames = function () {
|
|
80
|
+
return Object.keys(this.splitsCache);
|
|
81
|
+
};
|
|
82
|
+
SplitsCacheInMemory.prototype.trafficTypeExists = function (trafficType) {
|
|
83
|
+
return (0, lang_1.isFiniteNumber)(this.ttCache[trafficType]) && this.ttCache[trafficType] > 0;
|
|
84
|
+
};
|
|
85
|
+
SplitsCacheInMemory.prototype.usesSegments = function () {
|
|
86
|
+
return this.getChangeNumber() === -1 || this.segmentsCount > 0;
|
|
87
|
+
};
|
|
88
|
+
SplitsCacheInMemory.prototype.getNamesByFlagSets = function (flagSets) {
|
|
89
|
+
var _this = this;
|
|
90
|
+
return flagSets.map(function (flagSet) { return _this.flagSetsCache[flagSet] || new Set(); });
|
|
91
|
+
};
|
|
92
|
+
SplitsCacheInMemory.prototype.addToFlagSets = function (featureFlag) {
|
|
93
|
+
var _this = this;
|
|
94
|
+
if (!featureFlag.sets)
|
|
95
|
+
return;
|
|
96
|
+
featureFlag.sets.forEach(function (featureFlagSet) {
|
|
97
|
+
if (_this.flagSetsFilter.length > 0 && !_this.flagSetsFilter.some(function (filterFlagSet) { return filterFlagSet === featureFlagSet; }))
|
|
98
|
+
return;
|
|
99
|
+
if (!_this.flagSetsCache[featureFlagSet])
|
|
100
|
+
_this.flagSetsCache[featureFlagSet] = new Set([]);
|
|
101
|
+
_this.flagSetsCache[featureFlagSet].add(featureFlag.name);
|
|
102
|
+
});
|
|
103
|
+
};
|
|
104
|
+
SplitsCacheInMemory.prototype.removeFromFlagSets = function (featureFlagName, flagSets) {
|
|
105
|
+
var _this = this;
|
|
106
|
+
if (!flagSets)
|
|
107
|
+
return;
|
|
108
|
+
flagSets.forEach(function (flagSet) {
|
|
109
|
+
_this.removeNames(flagSet, featureFlagName);
|
|
110
|
+
});
|
|
111
|
+
};
|
|
112
|
+
SplitsCacheInMemory.prototype.removeNames = function (flagSetName, featureFlagName) {
|
|
113
|
+
if (!this.flagSetsCache[flagSetName])
|
|
114
|
+
return;
|
|
115
|
+
this.flagSetsCache[flagSetName].delete(featureFlagName);
|
|
116
|
+
if (this.flagSetsCache[flagSetName].size === 0)
|
|
117
|
+
delete this.flagSetsCache[flagSetName];
|
|
118
|
+
};
|
|
119
|
+
return SplitsCacheInMemory;
|
|
120
|
+
}(AbstractSplitsCacheSync_1.AbstractSplitsCacheSync));
|
|
121
|
+
exports.SplitsCacheInMemory = SplitsCacheInMemory;
|
|
@@ -19,13 +19,13 @@ var ACCEPTANCE_RANGE = 0.001;
|
|
|
19
19
|
* All factory instances track telemetry on server-side, and 0.1% on client-side.
|
|
20
20
|
*/
|
|
21
21
|
function shouldRecordTelemetry(_a) {
|
|
22
|
-
var settings = _a.settings
|
|
23
|
-
return
|
|
22
|
+
var settings = _a.settings;
|
|
23
|
+
return settings.mode !== constants_1.LOCALHOST_MODE && ((0, key_1.checkIfServerSide)(settings) || Math.random() <= ACCEPTANCE_RANGE);
|
|
24
24
|
}
|
|
25
25
|
exports.shouldRecordTelemetry = shouldRecordTelemetry;
|
|
26
26
|
var TelemetryCacheInMemory = /** @class */ (function () {
|
|
27
|
-
function TelemetryCacheInMemory(
|
|
28
|
-
this.
|
|
27
|
+
function TelemetryCacheInMemory(splits, segments, largeSegments) {
|
|
28
|
+
this.splits = splits;
|
|
29
29
|
this.segments = segments;
|
|
30
30
|
this.largeSegments = largeSegments;
|
|
31
31
|
this.name = 'telemetry stats';
|
|
@@ -61,7 +61,7 @@ var TelemetryCacheInMemory = /** @class */ (function () {
|
|
|
61
61
|
iQ: this.getImpressionStats(constants_1.QUEUED),
|
|
62
62
|
iDe: this.getImpressionStats(constants_1.DEDUPED),
|
|
63
63
|
iDr: this.getImpressionStats(constants_1.DROPPED),
|
|
64
|
-
spC: this.
|
|
64
|
+
spC: this.splits && this.splits.getSplitNames().length,
|
|
65
65
|
seC: this.segments && this.segments.getRegisteredSegments().length,
|
|
66
66
|
skC: this.segments && this.segments.getKeysCount(),
|
|
67
67
|
lsC: this.largeSegments && this.largeSegments.getRegisteredSegments().length,
|
|
@@ -34,7 +34,7 @@ var RBSegmentsCacheInRedis = /** @class */ (function () {
|
|
|
34
34
|
return _this.redis.set(key, stringifiedNewRBSegment).then(function () { return true; });
|
|
35
35
|
})),
|
|
36
36
|
Promise.all(toRemove.map(function (toRemove) {
|
|
37
|
-
var key = _this.keys.buildRBSegmentKey(toRemove);
|
|
37
|
+
var key = _this.keys.buildRBSegmentKey(toRemove.name);
|
|
38
38
|
return _this.redis.del(key).then(function (status) { return status === 1; });
|
|
39
39
|
}))
|
|
40
40
|
]).then(function (_a) {
|
|
@@ -3,7 +3,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.RedisAdapter = void 0;
|
|
4
4
|
var tslib_1 = require("tslib");
|
|
5
5
|
// Dynamically require ioredis to prevent strict TypeScript binding
|
|
6
|
-
// and handle module export differences between v4 and
|
|
6
|
+
// and handle module export differences between v4 and later major versions.
|
|
7
7
|
var RedisConstructor;
|
|
8
8
|
try {
|
|
9
9
|
var ioredisLib = require('ioredis');
|
|
@@ -11,7 +11,7 @@ try {
|
|
|
11
11
|
}
|
|
12
12
|
catch (e) {
|
|
13
13
|
// If we reach here, the peer dependency is missing
|
|
14
|
-
throw new Error('ioredis is missing. Please install ioredis v4 or
|
|
14
|
+
throw new Error('ioredis is missing. Please install ioredis v4, v5 or v6.');
|
|
15
15
|
}
|
|
16
16
|
var lang_1 = require("../../utils/lang");
|
|
17
17
|
var thenable_1 = require("../../utils/promise/thenable");
|
|
@@ -31,13 +31,16 @@ var DEFAULT_LIBRARY_OPTIONS = {
|
|
|
31
31
|
enableOfflineQueue: false,
|
|
32
32
|
connectTimeout: DEFAULT_OPTIONS.connectionTimeout,
|
|
33
33
|
lazyConnect: false,
|
|
34
|
-
// CRITICAL: v5
|
|
35
|
-
// v4 defaulted to 5000. We explicitly set it here to ensure v5
|
|
34
|
+
// CRITICAL: v5 and v6 default this to 0 (disabled), which breaks dynamic clusters.
|
|
35
|
+
// v4 defaulted to 5000. We explicitly set it here to ensure v5 and v6 work like v4.
|
|
36
36
|
slotsRefreshInterval: 5000,
|
|
37
|
+
// v6 defaults to RESP3 (`protocol: 3`). The SDK doesn't use any RESP3 feature,
|
|
38
|
+
// so we stick to RESP2 to keep the v4 and v5 behavior. Ignored by v4 and v5.
|
|
39
|
+
protocol: 2,
|
|
37
40
|
};
|
|
38
41
|
/**
|
|
39
42
|
* Redis adapter on top of the library of choice (written with ioredis) for some extra control.
|
|
40
|
-
* Refactored to use Composition instead of Inheritance to support
|
|
43
|
+
* Refactored to use Composition instead of Inheritance to support v4, v5 and v6.
|
|
41
44
|
*/
|
|
42
45
|
var RedisAdapter = /** @class */ (function () {
|
|
43
46
|
function RedisAdapter(log, storageSettings) {
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.
|
|
3
|
+
exports.SplitsCacheInRedis = void 0;
|
|
4
4
|
var tslib_1 = require("tslib");
|
|
5
5
|
var lang_1 = require("../../utils/lang");
|
|
6
6
|
var constants_1 = require("./constants");
|
|
7
|
-
var
|
|
7
|
+
var AbstractSplitsCacheAsync_1 = require("../AbstractSplitsCacheAsync");
|
|
8
8
|
var sets_1 = require("../../utils/lang/sets");
|
|
9
9
|
/**
|
|
10
10
|
* Discard errors for an answer of multiple operations.
|
|
@@ -17,17 +17,17 @@ function processPipelineAnswer(results) {
|
|
|
17
17
|
}, []) : [];
|
|
18
18
|
}
|
|
19
19
|
/**
|
|
20
|
-
*
|
|
20
|
+
* ISplitsCacheAsync implementation that stores split definitions in Redis.
|
|
21
21
|
* Supported by Node.js
|
|
22
22
|
*/
|
|
23
|
-
var
|
|
24
|
-
tslib_1.__extends(
|
|
25
|
-
function
|
|
23
|
+
var SplitsCacheInRedis = /** @class */ (function (_super) {
|
|
24
|
+
tslib_1.__extends(SplitsCacheInRedis, _super);
|
|
25
|
+
function SplitsCacheInRedis(log, keys, redis, splitFiltersValidation) {
|
|
26
26
|
var _this = _super.call(this) || this;
|
|
27
27
|
_this.log = log;
|
|
28
28
|
_this.redis = redis;
|
|
29
29
|
_this.keys = keys;
|
|
30
|
-
_this.
|
|
30
|
+
_this.flagSetsFilter = splitFiltersValidation ? splitFiltersValidation.groupedFilters.bySet : [];
|
|
31
31
|
// There is no need to listen for redis 'error' event, because in that case ioredis calls will be rejected and handled by redis storage adapters.
|
|
32
32
|
// But it is done just to avoid getting the ioredis message `Unhandled error event`.
|
|
33
33
|
_this.redis.on('error', function (e) {
|
|
@@ -38,104 +38,104 @@ var DefinitionsCacheInRedis = /** @class */ (function (_super) {
|
|
|
38
38
|
});
|
|
39
39
|
return _this;
|
|
40
40
|
}
|
|
41
|
-
|
|
41
|
+
SplitsCacheInRedis.prototype._decrementCounts = function (split) {
|
|
42
42
|
var _this = this;
|
|
43
|
-
var ttKey = this.keys.buildTrafficTypeKey(
|
|
43
|
+
var ttKey = this.keys.buildTrafficTypeKey(split.trafficTypeName);
|
|
44
44
|
return this.redis.decr(ttKey).then(function (count) {
|
|
45
45
|
if (count === 0)
|
|
46
46
|
return _this.redis.del(ttKey);
|
|
47
47
|
});
|
|
48
48
|
};
|
|
49
|
-
|
|
50
|
-
var ttKey = this.keys.buildTrafficTypeKey(
|
|
49
|
+
SplitsCacheInRedis.prototype._incrementCounts = function (split) {
|
|
50
|
+
var ttKey = this.keys.buildTrafficTypeKey(split.trafficTypeName);
|
|
51
51
|
return this.redis.incr(ttKey);
|
|
52
52
|
};
|
|
53
|
-
|
|
53
|
+
SplitsCacheInRedis.prototype._updateFlagSets = function (featureFlagName, flagSetsOfRemovedFlag, flagSetsOfAddedFlag) {
|
|
54
54
|
var _this = this;
|
|
55
|
-
var
|
|
56
|
-
var
|
|
57
|
-
if (this.
|
|
58
|
-
|
|
59
|
-
return _this.
|
|
55
|
+
var removeFromFlagSets = (0, sets_1.returnDifference)(flagSetsOfRemovedFlag, flagSetsOfAddedFlag);
|
|
56
|
+
var addToFlagSets = (0, sets_1.returnDifference)(flagSetsOfAddedFlag, flagSetsOfRemovedFlag);
|
|
57
|
+
if (this.flagSetsFilter.length > 0) {
|
|
58
|
+
addToFlagSets = addToFlagSets.filter(function (flagSet) {
|
|
59
|
+
return _this.flagSetsFilter.some(function (filterFlagSet) { return filterFlagSet === flagSet; });
|
|
60
60
|
});
|
|
61
61
|
}
|
|
62
|
-
var items = [
|
|
63
|
-
return Promise.all(tslib_1.__spreadArray(tslib_1.__spreadArray([],
|
|
62
|
+
var items = [featureFlagName];
|
|
63
|
+
return Promise.all(tslib_1.__spreadArray(tslib_1.__spreadArray([], removeFromFlagSets.map(function (flagSetName) { return _this.redis.srem(_this.keys.buildFlagSetKey(flagSetName), items); }), true), addToFlagSets.map(function (flagSetName) { return _this.redis.sadd(_this.keys.buildFlagSetKey(flagSetName), items); }), true));
|
|
64
64
|
};
|
|
65
65
|
/**
|
|
66
|
-
* Add a given
|
|
66
|
+
* Add a given split.
|
|
67
67
|
* The returned promise is resolved when the operation success
|
|
68
68
|
* or rejected if it fails (e.g., redis operation fails)
|
|
69
69
|
*/
|
|
70
|
-
|
|
70
|
+
SplitsCacheInRedis.prototype.addSplit = function (split) {
|
|
71
71
|
var _this = this;
|
|
72
|
-
var name =
|
|
73
|
-
var
|
|
74
|
-
return this.redis.get(
|
|
72
|
+
var name = split.name;
|
|
73
|
+
var splitKey = this.keys.buildSplitKey(name);
|
|
74
|
+
return this.redis.get(splitKey).then(function (splitFromStorage) {
|
|
75
75
|
// handling parsing error
|
|
76
|
-
var
|
|
76
|
+
var parsedPreviousSplit, stringifiedNewSplit;
|
|
77
77
|
try {
|
|
78
|
-
|
|
79
|
-
|
|
78
|
+
parsedPreviousSplit = splitFromStorage ? JSON.parse(splitFromStorage) : undefined;
|
|
79
|
+
stringifiedNewSplit = JSON.stringify(split);
|
|
80
80
|
}
|
|
81
81
|
catch (e) {
|
|
82
82
|
throw new Error('Error parsing feature flag definition: ' + e);
|
|
83
83
|
}
|
|
84
|
-
return _this.redis.set(
|
|
84
|
+
return _this.redis.set(splitKey, stringifiedNewSplit).then(function () {
|
|
85
85
|
// avoid unnecessary increment/decrement operations
|
|
86
|
-
if (
|
|
86
|
+
if (parsedPreviousSplit && parsedPreviousSplit.trafficTypeName === split.trafficTypeName)
|
|
87
87
|
return;
|
|
88
88
|
// update traffic type counts
|
|
89
|
-
return _this._incrementCounts(
|
|
90
|
-
if (
|
|
91
|
-
return _this._decrementCounts(
|
|
89
|
+
return _this._incrementCounts(split).then(function () {
|
|
90
|
+
if (parsedPreviousSplit)
|
|
91
|
+
return _this._decrementCounts(parsedPreviousSplit);
|
|
92
92
|
});
|
|
93
|
-
}).then(function () { return _this.
|
|
93
|
+
}).then(function () { return _this._updateFlagSets(name, parsedPreviousSplit && parsedPreviousSplit.sets, split.sets); });
|
|
94
94
|
}).then(function () { return true; });
|
|
95
95
|
};
|
|
96
96
|
/**
|
|
97
|
-
* Remove a given
|
|
98
|
-
* The returned promise is resolved when the operation success, with true or false indicating if the
|
|
97
|
+
* Remove a given split.
|
|
98
|
+
* The returned promise is resolved when the operation success, with true or false indicating if the split existed (and was removed) or not.
|
|
99
99
|
* or rejected if it fails (e.g., redis operation fails).
|
|
100
100
|
*/
|
|
101
|
-
|
|
101
|
+
SplitsCacheInRedis.prototype.removeSplit = function (name) {
|
|
102
102
|
var _this = this;
|
|
103
|
-
return this.
|
|
104
|
-
if (
|
|
105
|
-
return _this._decrementCounts(
|
|
103
|
+
return this.getSplit(name).then(function (split) {
|
|
104
|
+
if (split) {
|
|
105
|
+
return _this._decrementCounts(split).then(function () { return _this._updateFlagSets(name, split.sets); });
|
|
106
106
|
}
|
|
107
107
|
}).then(function () {
|
|
108
|
-
return _this.redis.del(_this.keys.
|
|
108
|
+
return _this.redis.del(_this.keys.buildSplitKey(name)).then(function (status) { return status === 1; });
|
|
109
109
|
});
|
|
110
110
|
};
|
|
111
111
|
/**
|
|
112
|
-
* Get definition or null if it's not defined.
|
|
112
|
+
* Get split definition or null if it's not defined.
|
|
113
113
|
* Returned promise is rejected if redis operation fails.
|
|
114
114
|
*/
|
|
115
|
-
|
|
115
|
+
SplitsCacheInRedis.prototype.getSplit = function (name) {
|
|
116
116
|
if (this.redisError) {
|
|
117
117
|
this.log.error(constants_1.LOG_PREFIX + this.redisError);
|
|
118
118
|
return Promise.reject(this.redisError);
|
|
119
119
|
}
|
|
120
|
-
return this.redis.get(this.keys.
|
|
121
|
-
.then(function (
|
|
120
|
+
return this.redis.get(this.keys.buildSplitKey(name))
|
|
121
|
+
.then(function (maybeSplit) { return maybeSplit && JSON.parse(maybeSplit); });
|
|
122
122
|
};
|
|
123
123
|
/**
|
|
124
124
|
* Set till number.
|
|
125
125
|
* The returned promise is resolved when the operation success,
|
|
126
126
|
* or rejected if it fails.
|
|
127
127
|
*/
|
|
128
|
-
|
|
129
|
-
return this.redis.set(this.keys.
|
|
128
|
+
SplitsCacheInRedis.prototype.setChangeNumber = function (changeNumber) {
|
|
129
|
+
return this.redis.set(this.keys.buildSplitsTillKey(), changeNumber + '').then(function (status) { return status === 'OK'; });
|
|
130
130
|
};
|
|
131
131
|
/**
|
|
132
132
|
* Get till number or -1 if it's not defined.
|
|
133
133
|
* The returned promise is resolved with the changeNumber or -1 if it doesn't exist or a redis operation fails.
|
|
134
134
|
* The promise will never be rejected.
|
|
135
135
|
*/
|
|
136
|
-
|
|
136
|
+
SplitsCacheInRedis.prototype.getChangeNumber = function () {
|
|
137
137
|
var _this = this;
|
|
138
|
-
return this.redis.get(this.keys.
|
|
138
|
+
return this.redis.get(this.keys.buildSplitsTillKey()).then(function (value) {
|
|
139
139
|
var i = parseInt(value, 10);
|
|
140
140
|
return (0, lang_1.isNaNNumber)(i) ? -1 : i;
|
|
141
141
|
}).catch(function (e) {
|
|
@@ -144,44 +144,44 @@ var DefinitionsCacheInRedis = /** @class */ (function (_super) {
|
|
|
144
144
|
});
|
|
145
145
|
};
|
|
146
146
|
/**
|
|
147
|
-
* Get list of all definitions.
|
|
148
|
-
* The returned promise is resolved with the list of definitions,
|
|
147
|
+
* Get list of all split definitions.
|
|
148
|
+
* The returned promise is resolved with the list of split definitions,
|
|
149
149
|
* or rejected if redis operation fails.
|
|
150
150
|
*/
|
|
151
151
|
// @TODO we need to benchmark which is the maximun number of commands we could pipeline without kill redis performance.
|
|
152
|
-
|
|
152
|
+
SplitsCacheInRedis.prototype.getAll = function () {
|
|
153
153
|
var _this = this;
|
|
154
|
-
return this.redis.keys(this.keys.
|
|
154
|
+
return this.redis.keys(this.keys.searchPatternForSplitKeys())
|
|
155
155
|
.then(function (listOfKeys) { return _this.redis.pipeline(listOfKeys.map(function (k) { return ['get', k]; })).exec(); })
|
|
156
156
|
.then(processPipelineAnswer)
|
|
157
|
-
.then(function (
|
|
158
|
-
return JSON.parse(
|
|
157
|
+
.then(function (splitDefinitions) { return splitDefinitions.map(function (splitDefinition) {
|
|
158
|
+
return JSON.parse(splitDefinition);
|
|
159
159
|
}); });
|
|
160
160
|
};
|
|
161
161
|
/**
|
|
162
|
-
* Get list of
|
|
163
|
-
* The returned promise is resolved with the list of names,
|
|
162
|
+
* Get list of split names.
|
|
163
|
+
* The returned promise is resolved with the list of split names,
|
|
164
164
|
* or rejected if redis operation fails.
|
|
165
165
|
*/
|
|
166
|
-
|
|
166
|
+
SplitsCacheInRedis.prototype.getSplitNames = function () {
|
|
167
167
|
var _this = this;
|
|
168
|
-
return this.redis.keys(this.keys.
|
|
168
|
+
return this.redis.keys(this.keys.searchPatternForSplitKeys()).then(function (listOfKeys) { return listOfKeys.map(_this.keys.extractKey); });
|
|
169
169
|
};
|
|
170
170
|
/**
|
|
171
|
-
* Get list of
|
|
172
|
-
* The returned promise is resolved with the list of names per set,
|
|
171
|
+
* Get list of feature flag names related to a given list of flag set names.
|
|
172
|
+
* The returned promise is resolved with the list of feature flag names per flag set,
|
|
173
173
|
* or rejected if the pipelined redis operation fails (e.g., timeout).
|
|
174
174
|
*/
|
|
175
|
-
|
|
175
|
+
SplitsCacheInRedis.prototype.getNamesByFlagSets = function (flagSets) {
|
|
176
176
|
var _this = this;
|
|
177
|
-
return this.redis.pipeline(
|
|
177
|
+
return this.redis.pipeline(flagSets.map(function (flagSet) { return ['smembers', _this.keys.buildFlagSetKey(flagSet)]; })).exec()
|
|
178
178
|
.then(function (results) { return results ? results.map(function (_a, index) {
|
|
179
179
|
var e = _a[0], value = _a[1];
|
|
180
180
|
if (e === null)
|
|
181
181
|
return value;
|
|
182
|
-
_this.log.error(constants_1.LOG_PREFIX + "Could not read result from get members of set ".concat(
|
|
182
|
+
_this.log.error(constants_1.LOG_PREFIX + "Could not read result from get members of flag set ".concat(flagSets[index], " due to an error: ").concat(e));
|
|
183
183
|
}) : []; })
|
|
184
|
-
.then(function (
|
|
184
|
+
.then(function (namesByFlagSets) { return namesByFlagSets.map(function (namesByFlagSet) { return new Set(namesByFlagSet); }); });
|
|
185
185
|
};
|
|
186
186
|
/**
|
|
187
187
|
* Check traffic type existence.
|
|
@@ -189,7 +189,7 @@ var DefinitionsCacheInRedis = /** @class */ (function (_super) {
|
|
|
189
189
|
* In case of redis operation failure, the promise resolves with a true value, assuming that the TT might exist.
|
|
190
190
|
* It will never be rejected.
|
|
191
191
|
*/
|
|
192
|
-
|
|
192
|
+
SplitsCacheInRedis.prototype.trafficTypeExists = function (trafficType) {
|
|
193
193
|
var _this = this;
|
|
194
194
|
// If there is a number there should be > 0, otherwise the TT is considered as not existent.
|
|
195
195
|
return this.redis.get(this.keys.buildTrafficTypeKey(trafficType))
|
|
@@ -210,34 +210,34 @@ var DefinitionsCacheInRedis = /** @class */ (function (_super) {
|
|
|
210
210
|
});
|
|
211
211
|
};
|
|
212
212
|
// @TODO remove or implement. It is not being used.
|
|
213
|
-
|
|
213
|
+
SplitsCacheInRedis.prototype.clear = function () {
|
|
214
214
|
return Promise.resolve();
|
|
215
215
|
};
|
|
216
216
|
/**
|
|
217
|
-
* Fetches multiple definitions.
|
|
217
|
+
* Fetches multiple splits definitions.
|
|
218
218
|
* Returned promise is rejected if redis operation fails.
|
|
219
219
|
*/
|
|
220
|
-
|
|
220
|
+
SplitsCacheInRedis.prototype.getSplits = function (names) {
|
|
221
221
|
var _a;
|
|
222
222
|
var _this = this;
|
|
223
223
|
if (this.redisError) {
|
|
224
224
|
this.log.error(constants_1.LOG_PREFIX + this.redisError);
|
|
225
225
|
return Promise.reject(this.redisError);
|
|
226
226
|
}
|
|
227
|
-
var keys = names.map(function (name) { return _this.keys.
|
|
228
|
-
return (_a = this.redis).mget.apply(_a, keys).then(function (
|
|
229
|
-
var
|
|
227
|
+
var keys = names.map(function (name) { return _this.keys.buildSplitKey(name); });
|
|
228
|
+
return (_a = this.redis).mget.apply(_a, keys).then(function (splitDefinitions) {
|
|
229
|
+
var splits = {};
|
|
230
230
|
names.forEach(function (name, idx) {
|
|
231
|
-
var
|
|
232
|
-
|
|
231
|
+
var split = splitDefinitions[idx];
|
|
232
|
+
splits[name] = split && JSON.parse(split);
|
|
233
233
|
});
|
|
234
|
-
return Promise.resolve(
|
|
234
|
+
return Promise.resolve(splits);
|
|
235
235
|
})
|
|
236
236
|
.catch(function (e) {
|
|
237
237
|
_this.log.error(constants_1.LOG_PREFIX + "Could not grab feature flags due to an error: ".concat(e, "."));
|
|
238
238
|
return Promise.reject(e);
|
|
239
239
|
});
|
|
240
240
|
};
|
|
241
|
-
return
|
|
242
|
-
}(
|
|
243
|
-
exports.
|
|
241
|
+
return SplitsCacheInRedis;
|
|
242
|
+
}(AbstractSplitsCacheAsync_1.AbstractSplitsCacheAsync));
|
|
243
|
+
exports.SplitsCacheInRedis = SplitsCacheInRedis;
|
|
@@ -3,7 +3,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.InRedisStorage = void 0;
|
|
4
4
|
var KeyBuilder_1 = require("../KeyBuilder");
|
|
5
5
|
var KeyBuilderSS_1 = require("../KeyBuilderSS");
|
|
6
|
-
var
|
|
6
|
+
var SplitsCacheInRedis_1 = require("./SplitsCacheInRedis");
|
|
7
7
|
var SegmentsCacheInRedis_1 = require("./SegmentsCacheInRedis");
|
|
8
8
|
var ImpressionsCacheInRedis_1 = require("./ImpressionsCacheInRedis");
|
|
9
9
|
var EventsCacheInRedis_1 = require("./EventsCacheInRedis");
|
|
@@ -48,7 +48,7 @@ function InRedisStorage(options) {
|
|
|
48
48
|
telemetry.recordConfig();
|
|
49
49
|
});
|
|
50
50
|
return {
|
|
51
|
-
|
|
51
|
+
splits: new SplitsCacheInRedis_1.SplitsCacheInRedis(log, keys, redisClient, settings.sync.__splitFiltersValidation),
|
|
52
52
|
rbSegments: new RBSegmentsCacheInRedis_1.RBSegmentsCacheInRedis(log, keys, redisClient),
|
|
53
53
|
segments: new SegmentsCacheInRedis_1.SegmentsCacheInRedis(log, keys, redisClient),
|
|
54
54
|
impressions: new ImpressionsCacheInRedis_1.ImpressionsCacheInRedis(log, keys.buildImpressionsKey(), redisClient, metadata),
|
|
@@ -34,7 +34,7 @@ var RBSegmentsCachePluggable = /** @class */ (function () {
|
|
|
34
34
|
return _this.wrapper.set(key, stringifiedNewRBSegment).then(function () { return true; });
|
|
35
35
|
})),
|
|
36
36
|
Promise.all(toRemove.map(function (toRemove) {
|
|
37
|
-
var key = _this.keys.buildRBSegmentKey(toRemove);
|
|
37
|
+
var key = _this.keys.buildRBSegmentKey(toRemove.name);
|
|
38
38
|
return _this.wrapper.del(key);
|
|
39
39
|
}))
|
|
40
40
|
]).then(function (_a) {
|