@splitsoftware/splitio-commons 2.2.1-rc.5 → 2.3.0
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 +26 -26
- package/README.md +0 -1
- package/cjs/evaluator/combiners/and.js +6 -2
- package/cjs/evaluator/combiners/ifelseif.js +6 -6
- package/cjs/evaluator/condition/index.js +5 -6
- package/cjs/evaluator/index.js +7 -7
- package/cjs/evaluator/matchers/index.js +1 -3
- package/cjs/evaluator/matchers/matcherTypes.js +0 -1
- package/cjs/evaluator/matchersTransform/index.js +0 -4
- package/cjs/evaluator/parser/index.js +2 -2
- package/cjs/evaluator/value/sanitize.js +0 -1
- package/cjs/logger/constants.js +3 -4
- package/cjs/logger/messages/debug.js +2 -3
- package/cjs/logger/messages/warn.js +1 -1
- package/cjs/services/splitApi.js +4 -3
- package/cjs/services/splitHttpClient.js +3 -2
- package/cjs/storages/AbstractSplitsCacheSync.js +2 -5
- package/cjs/storages/KeyBuilder.js +0 -9
- package/cjs/storages/KeyBuilderCS.js +0 -3
- package/cjs/storages/KeyBuilderSS.js +0 -3
- package/cjs/storages/inLocalStorage/SplitsCacheInLocal.js +14 -9
- package/cjs/storages/inLocalStorage/index.js +1 -5
- package/cjs/storages/inLocalStorage/validateCache.js +1 -2
- package/cjs/storages/inMemory/InMemoryStorage.js +0 -3
- package/cjs/storages/inMemory/InMemoryStorageCS.js +0 -4
- package/cjs/storages/inMemory/SplitsCacheInMemory.js +0 -1
- package/cjs/storages/inRedis/index.js +0 -2
- package/cjs/storages/pluggable/index.js +0 -2
- package/cjs/sync/polling/fetchers/splitChangesFetcher.js +4 -54
- package/cjs/sync/polling/pollingManagerCS.js +7 -7
- package/cjs/sync/polling/syncTasks/splitsSyncTask.js +1 -1
- package/cjs/sync/polling/updaters/mySegmentsUpdater.js +2 -2
- package/cjs/sync/polling/updaters/segmentChangesUpdater.js +1 -1
- package/cjs/sync/polling/updaters/splitChangesUpdater.js +33 -59
- package/cjs/sync/streaming/SSEHandler/index.js +0 -1
- package/cjs/sync/streaming/UpdateWorkers/SplitsUpdateWorker.js +77 -106
- package/cjs/sync/streaming/constants.js +1 -2
- package/cjs/sync/streaming/pushManager.js +16 -3
- package/cjs/sync/syncManagerOnline.js +2 -2
- package/cjs/utils/constants/index.js +2 -6
- package/esm/evaluator/combiners/and.js +6 -2
- package/esm/evaluator/combiners/ifelseif.js +7 -7
- package/esm/evaluator/condition/index.js +5 -6
- package/esm/evaluator/index.js +7 -7
- package/esm/evaluator/matchers/index.js +1 -3
- package/esm/evaluator/matchers/matcherTypes.js +0 -1
- package/esm/evaluator/matchersTransform/index.js +0 -4
- package/esm/evaluator/parser/index.js +2 -2
- package/esm/evaluator/value/sanitize.js +0 -1
- package/esm/logger/constants.js +0 -1
- package/esm/logger/messages/debug.js +2 -3
- package/esm/logger/messages/warn.js +1 -1
- package/esm/services/splitApi.js +4 -3
- package/esm/services/splitHttpClient.js +3 -2
- package/esm/storages/AbstractSplitsCacheSync.js +2 -5
- package/esm/storages/KeyBuilder.js +0 -9
- package/esm/storages/KeyBuilderCS.js +0 -3
- package/esm/storages/KeyBuilderSS.js +0 -3
- package/esm/storages/inLocalStorage/SplitsCacheInLocal.js +14 -9
- package/esm/storages/inLocalStorage/index.js +1 -5
- package/esm/storages/inLocalStorage/validateCache.js +1 -2
- package/esm/storages/inMemory/InMemoryStorage.js +0 -3
- package/esm/storages/inMemory/InMemoryStorageCS.js +0 -4
- package/esm/storages/inMemory/SplitsCacheInMemory.js +0 -1
- package/esm/storages/inRedis/index.js +0 -2
- package/esm/storages/pluggable/index.js +0 -2
- package/esm/sync/polling/fetchers/splitChangesFetcher.js +4 -54
- package/esm/sync/polling/pollingManagerCS.js +7 -7
- package/esm/sync/polling/syncTasks/splitsSyncTask.js +1 -1
- package/esm/sync/polling/updaters/mySegmentsUpdater.js +2 -2
- package/esm/sync/polling/updaters/segmentChangesUpdater.js +1 -1
- package/esm/sync/polling/updaters/splitChangesUpdater.js +33 -59
- package/esm/sync/streaming/SSEHandler/index.js +1 -2
- package/esm/sync/streaming/UpdateWorkers/SplitsUpdateWorker.js +73 -102
- package/esm/sync/streaming/constants.js +0 -1
- package/esm/sync/streaming/pushManager.js +19 -6
- package/esm/sync/syncManagerOnline.js +2 -2
- package/esm/utils/constants/index.js +1 -5
- package/package.json +1 -1
- package/src/dtos/types.ts +8 -37
- package/src/evaluator/Engine.ts +1 -1
- package/src/evaluator/combiners/and.ts +4 -5
- package/src/evaluator/combiners/ifelseif.ts +9 -7
- package/src/evaluator/condition/engineUtils.ts +1 -1
- package/src/evaluator/condition/index.ts +12 -12
- package/src/evaluator/index.ts +7 -7
- package/src/evaluator/matchers/index.ts +1 -3
- package/src/evaluator/matchers/matcherTypes.ts +0 -1
- package/src/evaluator/matchersTransform/index.ts +0 -3
- package/src/evaluator/parser/index.ts +3 -3
- package/src/evaluator/types.ts +2 -2
- package/src/evaluator/value/index.ts +2 -2
- package/src/evaluator/value/sanitize.ts +4 -5
- package/src/logger/constants.ts +0 -1
- package/src/logger/messages/debug.ts +2 -3
- package/src/logger/messages/warn.ts +1 -1
- package/src/sdkFactory/types.ts +1 -1
- package/src/sdkManager/index.ts +1 -1
- package/src/services/splitApi.ts +4 -3
- package/src/services/splitHttpClient.ts +3 -2
- package/src/services/types.ts +1 -1
- package/src/storages/AbstractSplitsCacheSync.ts +3 -6
- package/src/storages/KeyBuilder.ts +0 -12
- package/src/storages/KeyBuilderCS.ts +0 -4
- package/src/storages/KeyBuilderSS.ts +0 -4
- package/src/storages/inLocalStorage/SplitsCacheInLocal.ts +14 -10
- package/src/storages/inLocalStorage/index.ts +1 -5
- package/src/storages/inLocalStorage/validateCache.ts +1 -3
- package/src/storages/inMemory/InMemoryStorage.ts +0 -3
- package/src/storages/inMemory/InMemoryStorageCS.ts +0 -4
- package/src/storages/inMemory/SplitsCacheInMemory.ts +0 -1
- package/src/storages/inRedis/index.ts +0 -2
- package/src/storages/pluggable/index.ts +0 -2
- package/src/storages/types.ts +1 -33
- package/src/sync/polling/fetchers/splitChangesFetcher.ts +4 -65
- package/src/sync/polling/fetchers/types.ts +0 -1
- package/src/sync/polling/pollingManagerCS.ts +7 -7
- package/src/sync/polling/syncTasks/splitsSyncTask.ts +1 -1
- package/src/sync/polling/types.ts +2 -2
- package/src/sync/polling/updaters/mySegmentsUpdater.ts +2 -2
- package/src/sync/polling/updaters/segmentChangesUpdater.ts +1 -1
- package/src/sync/polling/updaters/splitChangesUpdater.ts +43 -70
- package/src/sync/streaming/SSEHandler/index.ts +1 -2
- package/src/sync/streaming/SSEHandler/types.ts +2 -2
- package/src/sync/streaming/UpdateWorkers/SplitsUpdateWorker.ts +68 -98
- package/src/sync/streaming/constants.ts +0 -1
- package/src/sync/streaming/parseUtils.ts +2 -2
- package/src/sync/streaming/pushManager.ts +18 -6
- package/src/sync/streaming/types.ts +2 -3
- package/src/sync/syncManagerOnline.ts +2 -2
- package/src/utils/constants/index.ts +1 -6
- package/src/utils/lang/index.ts +1 -1
- package/cjs/evaluator/matchers/rbsegment.js +0 -56
- package/cjs/storages/inLocalStorage/RBSegmentsCacheInLocal.js +0 -117
- package/cjs/storages/inMemory/RBSegmentsCacheInMemory.js +0 -61
- package/cjs/storages/inRedis/RBSegmentsCacheInRedis.js +0 -64
- package/cjs/storages/pluggable/RBSegmentsCachePluggable.js +0 -64
- package/esm/evaluator/matchers/rbsegment.js +0 -52
- package/esm/storages/inLocalStorage/RBSegmentsCacheInLocal.js +0 -114
- package/esm/storages/inMemory/RBSegmentsCacheInMemory.js +0 -58
- package/esm/storages/inRedis/RBSegmentsCacheInRedis.js +0 -61
- package/esm/storages/pluggable/RBSegmentsCachePluggable.js +0 -61
- package/src/evaluator/matchers/rbsegment.ts +0 -74
- package/src/storages/inLocalStorage/RBSegmentsCacheInLocal.ts +0 -136
- package/src/storages/inMemory/RBSegmentsCacheInMemory.ts +0 -68
- package/src/storages/inRedis/RBSegmentsCacheInRedis.ts +0 -79
- package/src/storages/pluggable/RBSegmentsCachePluggable.ts +0 -76
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.ControlType = exports.OCCUPANCY = exports.CONTROL = exports.
|
|
3
|
+
exports.ControlType = exports.OCCUPANCY = exports.CONTROL = exports.SPLIT_UPDATE = exports.SPLIT_KILL = exports.SEGMENT_UPDATE = exports.MEMBERSHIPS_LS_UPDATE = exports.MEMBERSHIPS_MS_UPDATE = exports.PUSH_SUBSYSTEM_DOWN = exports.PUSH_SUBSYSTEM_UP = exports.PUSH_RETRYABLE_ERROR = exports.PUSH_NONRETRYABLE_ERROR = exports.SECONDS_BEFORE_EXPIRATION = void 0;
|
|
4
4
|
// time for refresh token
|
|
5
5
|
exports.SECONDS_BEFORE_EXPIRATION = 600;
|
|
6
6
|
// Internal SDK events, subscribed by SyncManager and PushManager
|
|
@@ -30,7 +30,6 @@ exports.MEMBERSHIPS_LS_UPDATE = 'MEMBERSHIPS_LS_UPDATE';
|
|
|
30
30
|
exports.SEGMENT_UPDATE = 'SEGMENT_UPDATE';
|
|
31
31
|
exports.SPLIT_KILL = 'SPLIT_KILL';
|
|
32
32
|
exports.SPLIT_UPDATE = 'SPLIT_UPDATE';
|
|
33
|
-
exports.RB_SEGMENT_UPDATE = 'RB_SEGMENT_UPDATE';
|
|
34
33
|
// Control-type push notifications, handled by NotificationKeeper
|
|
35
34
|
exports.CONTROL = 'CONTROL';
|
|
36
35
|
exports.OCCUPANCY = 'OCCUPANCY';
|
|
@@ -46,7 +46,7 @@ function pushManagerFactory(params, pollingManager) {
|
|
|
46
46
|
// MySegmentsUpdateWorker (client-side) are initiated in `add` method
|
|
47
47
|
var segmentsUpdateWorker = userKey ? undefined : (0, SegmentsUpdateWorker_1.SegmentsUpdateWorker)(log, pollingManager.segmentsSyncTask, storage.segments);
|
|
48
48
|
// For server-side we pass the segmentsSyncTask, used by SplitsUpdateWorker to fetch new segments
|
|
49
|
-
var splitsUpdateWorker = (0, SplitsUpdateWorker_1.SplitsUpdateWorker)(log, storage, pollingManager.splitsSyncTask, readiness.splits, telemetryTracker, userKey ? undefined : pollingManager.segmentsSyncTask);
|
|
49
|
+
var splitsUpdateWorker = (0, SplitsUpdateWorker_1.SplitsUpdateWorker)(log, storage.splits, pollingManager.splitsSyncTask, readiness.splits, telemetryTracker, userKey ? undefined : pollingManager.segmentsSyncTask);
|
|
50
50
|
// [Only for client-side] map of hashes to user keys, to dispatch membership update events to the corresponding MySegmentsUpdateWorker
|
|
51
51
|
var userKeyHashes = {};
|
|
52
52
|
// [Only for client-side] map of user keys to their corresponding hash64 and MySegmentsUpdateWorkers.
|
|
@@ -182,8 +182,21 @@ function pushManagerFactory(params, pollingManager) {
|
|
|
182
182
|
});
|
|
183
183
|
/** Functions related to synchronization (Queues and Workers in the spec) */
|
|
184
184
|
pushEmitter.on(constants_1.SPLIT_KILL, splitsUpdateWorker.killSplit);
|
|
185
|
-
pushEmitter.on(constants_1.SPLIT_UPDATE,
|
|
186
|
-
|
|
185
|
+
pushEmitter.on(constants_1.SPLIT_UPDATE, function (parsedData) {
|
|
186
|
+
if (parsedData.d && parsedData.c !== undefined) {
|
|
187
|
+
try {
|
|
188
|
+
var payload = (0, parseUtils_1.parseFFUpdatePayload)(parsedData.c, parsedData.d);
|
|
189
|
+
if (payload) {
|
|
190
|
+
splitsUpdateWorker.put(parsedData, payload);
|
|
191
|
+
return;
|
|
192
|
+
}
|
|
193
|
+
}
|
|
194
|
+
catch (e) {
|
|
195
|
+
log.warn(constants_2.STREAMING_PARSING_SPLIT_UPDATE, [e]);
|
|
196
|
+
}
|
|
197
|
+
}
|
|
198
|
+
splitsUpdateWorker.put(parsedData);
|
|
199
|
+
});
|
|
187
200
|
function handleMySegmentsUpdate(parsedData) {
|
|
188
201
|
switch (parsedData.u) {
|
|
189
202
|
case types_1.UpdateStrategy.BoundedFetchRequest: {
|
|
@@ -130,7 +130,7 @@ function syncManagerOnlineFactory(pollingManagerFactory, pushManagerFactory) {
|
|
|
130
130
|
if (pushManager) {
|
|
131
131
|
if (pollingManager.isRunning()) {
|
|
132
132
|
// if doing polling, we must start the periodic fetch of data
|
|
133
|
-
if (storage.splits.usesSegments()
|
|
133
|
+
if (storage.splits.usesSegments())
|
|
134
134
|
mySegmentsSyncTask.start();
|
|
135
135
|
}
|
|
136
136
|
else {
|
|
@@ -140,7 +140,7 @@ function syncManagerOnlineFactory(pollingManagerFactory, pushManagerFactory) {
|
|
|
140
140
|
}
|
|
141
141
|
}
|
|
142
142
|
else {
|
|
143
|
-
if (storage.splits.usesSegments()
|
|
143
|
+
if (storage.splits.usesSegments())
|
|
144
144
|
mySegmentsSyncTask.start();
|
|
145
145
|
}
|
|
146
146
|
}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.MEMBERSHIPS = exports.SEGMENT = exports.TOKEN = exports.TELEMETRY = exports.EVENTS = exports.IMPRESSIONS_COUNT = exports.IMPRESSIONS = exports.SPLITS = exports.NONE_ENUM = exports.DEBUG_ENUM = exports.OPTIMIZED_ENUM = exports.CONSUMER_PARTIAL_ENUM = exports.CONSUMER_ENUM = exports.STANDALONE_ENUM = exports.DEDUPED = exports.DROPPED = exports.QUEUED = exports.NAMES_FN_LABEL = exports.SPLITS_FN_LABEL = exports.SPLIT_FN_LABEL = exports.TRACK_FN_LABEL = exports.GET_TREATMENTS_WITH_CONFIG_BY_FLAG_SETS = exports.GET_TREATMENTS_WITH_CONFIG_BY_FLAG_SET = exports.GET_TREATMENTS_BY_FLAG_SETS = exports.GET_TREATMENTS_BY_FLAG_SET = exports.GET_TREATMENTS_WITH_CONFIG = exports.GET_TREATMENT_WITH_CONFIG = exports.GET_TREATMENTS = exports.GET_TREATMENT = exports.CONSENT_UNKNOWN = exports.CONSENT_DECLINED = exports.CONSENT_GRANTED = exports.STORAGE_PLUGGABLE = exports.STORAGE_REDIS = exports.STORAGE_LOCALSTORAGE = exports.STORAGE_MEMORY = exports.CONSUMER_PARTIAL_MODE = exports.CONSUMER_MODE = exports.PRODUCER_MODE = exports.STANDALONE_MODE = exports.LOCALHOST_MODE = exports.NONE = exports.OPTIMIZED = exports.DEBUG = exports.SPLIT_EVENT = exports.SPLIT_IMPRESSION = exports.NA = exports.UNKNOWN = exports.CONTROL_WITH_CONFIG = exports.CONTROL = void 0;
|
|
4
|
-
exports.
|
|
4
|
+
exports.IN_LARGE_SEGMENT = exports.IN_SEGMENT = exports.FLAG_SPEC_VERSION = exports.PAUSED = exports.ENABLED = exports.DISABLED = exports.NON_REQUESTED = exports.REQUESTED = exports.POLLING = exports.STREAMING = exports.AUTH_REJECTION = exports.SYNC_MODE_UPDATE = exports.ABLY_ERROR = exports.TOKEN_REFRESH = exports.SSE_CONNECTION_ERROR = exports.STREAMING_STATUS = exports.OCCUPANCY_SEC = exports.OCCUPANCY_PRI = exports.CONNECTION_ESTABLISHED = exports.TRACK = exports.TREATMENTS_WITH_CONFIG_BY_FLAGSETS = exports.TREATMENTS_WITH_CONFIG_BY_FLAGSET = exports.TREATMENTS_BY_FLAGSETS = exports.TREATMENTS_BY_FLAGSET = exports.TREATMENTS_WITH_CONFIG = exports.TREATMENT_WITH_CONFIG = exports.TREATMENTS = exports.TREATMENT = void 0;
|
|
5
5
|
// Special treatments
|
|
6
6
|
exports.CONTROL = 'control';
|
|
7
7
|
exports.CONTROL_WITH_CONFIG = {
|
|
@@ -90,11 +90,7 @@ exports.NON_REQUESTED = 1;
|
|
|
90
90
|
exports.DISABLED = 0;
|
|
91
91
|
exports.ENABLED = 1;
|
|
92
92
|
exports.PAUSED = 2;
|
|
93
|
-
exports.FLAG_SPEC_VERSION = '1.
|
|
93
|
+
exports.FLAG_SPEC_VERSION = '1.2';
|
|
94
94
|
// Matcher types
|
|
95
95
|
exports.IN_SEGMENT = 'IN_SEGMENT';
|
|
96
96
|
exports.IN_LARGE_SEGMENT = 'IN_LARGE_SEGMENT';
|
|
97
|
-
exports.IN_RULE_BASED_SEGMENT = 'IN_RULE_BASED_SEGMENT';
|
|
98
|
-
exports.STANDARD_SEGMENT = 'standard';
|
|
99
|
-
exports.LARGE_SEGMENT = 'large';
|
|
100
|
-
exports.RULE_BASED_SEGMENT = 'rule-based';
|
|
@@ -8,8 +8,12 @@ export function andCombinerContext(log, matchers) {
|
|
|
8
8
|
log.debug(ENGINE_COMBINER_AND, [hasMatchedAll]);
|
|
9
9
|
return hasMatchedAll;
|
|
10
10
|
}
|
|
11
|
-
return function andCombiner(
|
|
12
|
-
var
|
|
11
|
+
return function andCombiner() {
|
|
12
|
+
var params = [];
|
|
13
|
+
for (var _i = 0; _i < arguments.length; _i++) {
|
|
14
|
+
params[_i] = arguments[_i];
|
|
15
|
+
}
|
|
16
|
+
var matcherResults = matchers.map(function (matcher) { return matcher.apply(void 0, params); });
|
|
13
17
|
// If any matching result is a thenable we should use Promise.all
|
|
14
18
|
if (findIndex(matcherResults, thenable) !== -1) {
|
|
15
19
|
return Promise.all(matcherResults).then(andResults);
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { findIndex
|
|
1
|
+
import { findIndex } from '../../utils/lang';
|
|
2
2
|
import { thenable } from '../../utils/promise/thenable';
|
|
3
3
|
import { UNSUPPORTED_MATCHER_TYPE } from '../../utils/labels';
|
|
4
4
|
import { CONTROL } from '../../utils/constants';
|
|
@@ -11,12 +11,12 @@ export function ifElseIfCombinerContext(log, predicates) {
|
|
|
11
11
|
label: UNSUPPORTED_MATCHER_TYPE
|
|
12
12
|
};
|
|
13
13
|
}
|
|
14
|
-
function
|
|
15
|
-
|
|
14
|
+
function computeTreatment(predicateResults) {
|
|
15
|
+
var len = predicateResults.length;
|
|
16
|
+
for (var i = 0; i < len; i++) {
|
|
16
17
|
var evaluation = predicateResults[i];
|
|
17
18
|
if (evaluation !== undefined) {
|
|
18
|
-
|
|
19
|
-
log.debug(ENGINE_COMBINER_IFELSEIF, [evaluation.treatment]);
|
|
19
|
+
log.debug(ENGINE_COMBINER_IFELSEIF, [evaluation.treatment]);
|
|
20
20
|
return evaluation;
|
|
21
21
|
}
|
|
22
22
|
}
|
|
@@ -30,9 +30,9 @@ export function ifElseIfCombinerContext(log, predicates) {
|
|
|
30
30
|
var predicateResults = predicates.map(function (evaluator) { return evaluator(key, seed, trafficAllocation, trafficAllocationSeed, attributes, splitEvaluator); });
|
|
31
31
|
// if we find a thenable
|
|
32
32
|
if (findIndex(predicateResults, thenable) !== -1) {
|
|
33
|
-
return Promise.all(predicateResults).then(function (results) { return
|
|
33
|
+
return Promise.all(predicateResults).then(function (results) { return computeTreatment(results); });
|
|
34
34
|
}
|
|
35
|
-
return
|
|
35
|
+
return computeTreatment(predicateResults);
|
|
36
36
|
}
|
|
37
37
|
// if there is none predicates, then there was an error in parsing phase
|
|
38
38
|
if (!Array.isArray(predicates) || predicates.length === 0) {
|
|
@@ -4,12 +4,11 @@ import { NOT_IN_SPLIT } from '../../utils/labels';
|
|
|
4
4
|
// Build Evaluation object if and only if matchingResult is true
|
|
5
5
|
function match(log, matchingResult, bucketingKey, seed, treatments, label) {
|
|
6
6
|
if (matchingResult) {
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
true;
|
|
7
|
+
var treatment = getTreatment(log, bucketingKey, seed, treatments);
|
|
8
|
+
return {
|
|
9
|
+
treatment: treatment,
|
|
10
|
+
label: label
|
|
11
|
+
};
|
|
13
12
|
}
|
|
14
13
|
// else we should notify the engine to continue evaluating
|
|
15
14
|
return undefined;
|
package/esm/evaluator/index.js
CHANGED
|
@@ -26,12 +26,12 @@ export function evaluateFeature(log, key, splitName, attributes, storage) {
|
|
|
26
26
|
return treatmentException;
|
|
27
27
|
}
|
|
28
28
|
if (thenable(parsedSplit)) {
|
|
29
|
-
return parsedSplit.then(function (split) { return getEvaluation(log,
|
|
29
|
+
return parsedSplit.then(function (split) { return getEvaluation(log, split, key, attributes, storage); }).catch(
|
|
30
30
|
// Exception on async `getSplit` storage. For example, when the storage is redis or
|
|
31
31
|
// pluggable and there is a connection issue and we can't retrieve the split to be evaluated
|
|
32
32
|
function () { return treatmentException; });
|
|
33
33
|
}
|
|
34
|
-
return getEvaluation(log,
|
|
34
|
+
return getEvaluation(log, parsedSplit, key, attributes, storage);
|
|
35
35
|
}
|
|
36
36
|
export function evaluateFeatures(log, key, splitNames, attributes, storage) {
|
|
37
37
|
var parsedSplits;
|
|
@@ -43,13 +43,13 @@ export function evaluateFeatures(log, key, splitNames, attributes, storage) {
|
|
|
43
43
|
return treatmentsException(splitNames);
|
|
44
44
|
}
|
|
45
45
|
return thenable(parsedSplits) ?
|
|
46
|
-
parsedSplits.then(function (splits) { return getEvaluations(log,
|
|
46
|
+
parsedSplits.then(function (splits) { return getEvaluations(log, splitNames, splits, key, attributes, storage); })
|
|
47
47
|
.catch(function () {
|
|
48
48
|
// Exception on async `getSplits` storage. For example, when the storage is redis or
|
|
49
49
|
// pluggable and there is a connection issue and we can't retrieve the split to be evaluated
|
|
50
50
|
return treatmentsException(splitNames);
|
|
51
51
|
}) :
|
|
52
|
-
getEvaluations(log,
|
|
52
|
+
getEvaluations(log, splitNames, parsedSplits, key, attributes, storage);
|
|
53
53
|
}
|
|
54
54
|
export function evaluateFeaturesByFlagSets(log, key, flagSets, attributes, storage, method) {
|
|
55
55
|
var storedFlagNames;
|
|
@@ -84,7 +84,7 @@ export function evaluateFeaturesByFlagSets(log, key, flagSets, attributes, stora
|
|
|
84
84
|
}) :
|
|
85
85
|
evaluate(storedFlagNames);
|
|
86
86
|
}
|
|
87
|
-
function getEvaluation(log,
|
|
87
|
+
function getEvaluation(log, splitJSON, key, attributes, storage) {
|
|
88
88
|
var evaluation = {
|
|
89
89
|
treatment: CONTROL,
|
|
90
90
|
label: SPLIT_NOT_FOUND,
|
|
@@ -110,11 +110,11 @@ function getEvaluation(log, key, splitJSON, attributes, storage) {
|
|
|
110
110
|
}
|
|
111
111
|
return evaluation;
|
|
112
112
|
}
|
|
113
|
-
function getEvaluations(log,
|
|
113
|
+
function getEvaluations(log, splitNames, splits, key, attributes, storage) {
|
|
114
114
|
var result = {};
|
|
115
115
|
var thenables = [];
|
|
116
116
|
splitNames.forEach(function (splitName) {
|
|
117
|
-
var evaluation = getEvaluation(log,
|
|
117
|
+
var evaluation = getEvaluation(log, splits[splitName], key, attributes, storage);
|
|
118
118
|
if (thenable(evaluation)) {
|
|
119
119
|
thenables.push(evaluation.then(function (res) {
|
|
120
120
|
result[splitName] = res;
|
|
@@ -21,7 +21,6 @@ import { greaterThanEqualToSemverMatcherContext } from './semver_gte';
|
|
|
21
21
|
import { lessThanEqualToSemverMatcherContext } from './semver_lte';
|
|
22
22
|
import { betweenSemverMatcherContext } from './semver_between';
|
|
23
23
|
import { inListSemverMatcherContext } from './semver_inlist';
|
|
24
|
-
import { ruleBasedSegmentMatcherContext } from './rbsegment';
|
|
25
24
|
var matchers = [
|
|
26
25
|
undefined,
|
|
27
26
|
allMatcherContext,
|
|
@@ -46,8 +45,7 @@ var matchers = [
|
|
|
46
45
|
lessThanEqualToSemverMatcherContext,
|
|
47
46
|
betweenSemverMatcherContext,
|
|
48
47
|
inListSemverMatcherContext,
|
|
49
|
-
largeSegmentMatcherContext,
|
|
50
|
-
ruleBasedSegmentMatcherContext // IN_RULE_BASED_SEGMENT: 24
|
|
48
|
+
largeSegmentMatcherContext, // IN_LARGE_SEGMENT: 23
|
|
51
49
|
];
|
|
52
50
|
/**
|
|
53
51
|
* Matcher factory.
|
|
@@ -78,10 +78,6 @@ export function matchersTransform(matchers) {
|
|
|
78
78
|
type === matcherTypes.LESS_THAN_OR_EQUAL_TO_SEMVER) {
|
|
79
79
|
value = stringMatcherData;
|
|
80
80
|
}
|
|
81
|
-
else if (type === matcherTypes.IN_RULE_BASED_SEGMENT) {
|
|
82
|
-
value = segmentTransform(userDefinedSegmentMatcherData);
|
|
83
|
-
dataType = matcherDataTypes.NOT_SPECIFIED;
|
|
84
|
-
}
|
|
85
81
|
return {
|
|
86
82
|
attribute: attribute,
|
|
87
83
|
negate: negate,
|
|
@@ -50,8 +50,8 @@ export function parser(log, conditions, storage) {
|
|
|
50
50
|
// and break the loop
|
|
51
51
|
break;
|
|
52
52
|
}
|
|
53
|
-
predicates.push(conditionContext(log, andCombinerContext(log, expressions),
|
|
53
|
+
predicates.push(conditionContext(log, andCombinerContext(log, expressions), Treatments.parse(partitions), label, conditionType));
|
|
54
54
|
}
|
|
55
|
-
//
|
|
55
|
+
// Instanciate evaluator given the set of conditions using if else if logic
|
|
56
56
|
return ifElseIfCombinerContext(log, predicates);
|
|
57
57
|
}
|
|
@@ -49,7 +49,6 @@ function getProcessingFunction(matcherTypeID, dataType) {
|
|
|
49
49
|
case matcherTypes.BETWEEN:
|
|
50
50
|
return dataType === 'DATETIME' ? zeroSinceSS : undefined;
|
|
51
51
|
case matcherTypes.IN_SPLIT_TREATMENT:
|
|
52
|
-
case matcherTypes.IN_RULE_BASED_SEGMENT:
|
|
53
52
|
return dependencyProcessor;
|
|
54
53
|
default:
|
|
55
54
|
return undefined;
|
package/esm/logger/constants.js
CHANGED
|
@@ -21,7 +21,6 @@ export var RETRIEVE_MANAGER = 29;
|
|
|
21
21
|
export var SYNC_OFFLINE_DATA = 30;
|
|
22
22
|
export var SYNC_SPLITS_FETCH = 31;
|
|
23
23
|
export var SYNC_SPLITS_UPDATE = 32;
|
|
24
|
-
export var SYNC_RBS_UPDATE = 33;
|
|
25
24
|
export var STREAMING_NEW_MESSAGE = 35;
|
|
26
25
|
export var SYNC_TASK_START = 36;
|
|
27
26
|
export var SYNC_TASK_EXECUTE = 37;
|
|
@@ -19,9 +19,8 @@ export var codesDebug = codesInfo.concat([
|
|
|
19
19
|
[c.RETRIEVE_MANAGER, 'Retrieving manager instance.'],
|
|
20
20
|
// synchronizer
|
|
21
21
|
[c.SYNC_OFFLINE_DATA, c.LOG_PREFIX_SYNC_OFFLINE + 'Feature flags data: \n%s'],
|
|
22
|
-
[c.SYNC_SPLITS_FETCH, c.LOG_PREFIX_SYNC_SPLITS + 'Spin up feature flags update using since = %s
|
|
23
|
-
[c.SYNC_SPLITS_UPDATE, c.LOG_PREFIX_SYNC_SPLITS + 'New feature flags %s. Removed feature flags %s.'],
|
|
24
|
-
[c.SYNC_RBS_UPDATE, c.LOG_PREFIX_SYNC_SPLITS + 'New rule-based segments %s. Removed rule-based segments %s.'],
|
|
22
|
+
[c.SYNC_SPLITS_FETCH, c.LOG_PREFIX_SYNC_SPLITS + 'Spin up feature flags update using since = %s'],
|
|
23
|
+
[c.SYNC_SPLITS_UPDATE, c.LOG_PREFIX_SYNC_SPLITS + 'New feature flags %s. Removed feature flags %s. Segment names collected %s'],
|
|
25
24
|
[c.STREAMING_NEW_MESSAGE, c.LOG_PREFIX_SYNC_STREAMING + 'New SSE message received, with data: %s.'],
|
|
26
25
|
[c.SYNC_TASK_START, c.LOG_PREFIX_SYNC + ': Starting %s. Running each %s millis'],
|
|
27
26
|
[c.SYNC_TASK_EXECUTE, c.LOG_PREFIX_SYNC + ': Running %s'],
|
|
@@ -31,7 +31,7 @@ export var codesWarn = codesError.concat([
|
|
|
31
31
|
[c.WARN_SPLITS_FILTER_EMPTY, c.LOG_PREFIX_SETTINGS + ': feature flag filter configuration must be a non-empty array of filter objects.'],
|
|
32
32
|
[c.WARN_SDK_KEY, c.LOG_PREFIX_SETTINGS + ': You already have %s. We recommend keeping only one instance of the factory at all times (Singleton pattern) and reusing it throughout your application'],
|
|
33
33
|
[c.STREAMING_PARSING_MEMBERSHIPS_UPDATE, c.LOG_PREFIX_SYNC_STREAMING + 'Fetching Memberships due to an error processing %s notification: %s'],
|
|
34
|
-
[c.STREAMING_PARSING_SPLIT_UPDATE, c.LOG_PREFIX_SYNC_STREAMING + 'Fetching SplitChanges due to an error processing
|
|
34
|
+
[c.STREAMING_PARSING_SPLIT_UPDATE, c.LOG_PREFIX_SYNC_STREAMING + 'Fetching SplitChanges due to an error processing SPLIT_UPDATE notification: %s'],
|
|
35
35
|
[c.WARN_INVALID_FLAGSET, '%s: you passed %s, flag set must adhere to the regular expressions %s. This means a flag set must start with a letter or number, be in lowercase, alphanumeric and have a max length of 50 characters. %s was discarded.'],
|
|
36
36
|
[c.WARN_LOWERCASE_FLAGSET, '%s: flag set %s should be all lowercase - converting string to lowercase.'],
|
|
37
37
|
[c.WARN_FLAGSET_WITHOUT_FLAGS, '%s: you passed %s flag set that does not contain cached feature flag names. Please double check what flag sets are in use in the Split user interface.'],
|
package/esm/services/splitApi.js
CHANGED
|
@@ -17,6 +17,7 @@ export function splitApiFactory(settings, platform, telemetryTracker) {
|
|
|
17
17
|
var urls = settings.urls;
|
|
18
18
|
var filterQueryString = settings.sync.__splitFiltersValidation && settings.sync.__splitFiltersValidation.queryString;
|
|
19
19
|
var SplitSDKImpressionsMode = settings.sync.impressionsMode;
|
|
20
|
+
var flagSpecVersion = settings.sync.flagSpecVersion;
|
|
20
21
|
var splitHttpClient = splitHttpClientFactory(settings, platform);
|
|
21
22
|
return {
|
|
22
23
|
// @TODO throw errors if health check requests fail, to log them in the Synchronizer
|
|
@@ -29,7 +30,7 @@ export function splitApiFactory(settings, platform, telemetryTracker) {
|
|
|
29
30
|
return splitHttpClient(url).then(function () { return true; }).catch(function () { return false; });
|
|
30
31
|
},
|
|
31
32
|
fetchAuth: function (userMatchingKeys) {
|
|
32
|
-
var url = urls.auth + "/v2/auth?s=" +
|
|
33
|
+
var url = urls.auth + "/v2/auth?s=" + flagSpecVersion;
|
|
33
34
|
if (userMatchingKeys) { // `userMatchingKeys` is undefined in server-side
|
|
34
35
|
var queryParams = userMatchingKeys.map(userKeyToQueryParam).join('&');
|
|
35
36
|
if (queryParams)
|
|
@@ -37,8 +38,8 @@ export function splitApiFactory(settings, platform, telemetryTracker) {
|
|
|
37
38
|
}
|
|
38
39
|
return splitHttpClient(url, undefined, telemetryTracker.trackHttp(TOKEN));
|
|
39
40
|
},
|
|
40
|
-
fetchSplitChanges: function (since, noCache, till
|
|
41
|
-
var url = urls.sdk + "/splitChanges?s=" +
|
|
41
|
+
fetchSplitChanges: function (since, noCache, till) {
|
|
42
|
+
var url = urls.sdk + "/splitChanges?s=" + flagSpecVersion + "&since=" + since + (filterQueryString || '') + (till ? '&till=' + till : '');
|
|
42
43
|
return splitHttpClient(url, noCache ? noCacheHeaderOptions : undefined, telemetryTracker.trackHttp(SPLITS))
|
|
43
44
|
.catch(function (err) {
|
|
44
45
|
if (err.statusCode === 414)
|
|
@@ -2,6 +2,7 @@ import { objectAssign } from '../utils/lang/objectAssign';
|
|
|
2
2
|
import { ERROR_HTTP, ERROR_CLIENT_CANNOT_GET_READY } from '../logger/constants';
|
|
3
3
|
import { decorateHeaders, removeNonISO88591 } from './decorateHeaders';
|
|
4
4
|
import { timeout } from '../utils/promise/timeout';
|
|
5
|
+
var PENDING_FETCH_ERROR_TIMEOUT = 100;
|
|
5
6
|
var messageNoFetch = 'Global fetch API is not available.';
|
|
6
7
|
/**
|
|
7
8
|
* Factory of Split HTTP clients, which are HTTP clients with predefined headers for Split endpoints.
|
|
@@ -41,8 +42,8 @@ export function splitHttpClientFactory(settings, _a) {
|
|
|
41
42
|
// https://developer.mozilla.org/en-US/docs/Web/API/Fetch_API/Using_Fetch#Checking_that_the_fetch_was_successful
|
|
42
43
|
.then(function (response) {
|
|
43
44
|
if (!response.ok) {
|
|
44
|
-
//
|
|
45
|
-
return timeout(
|
|
45
|
+
// `text()` promise might not settle in some fetch implementations and cases (e.g. no content)
|
|
46
|
+
return timeout(PENDING_FETCH_ERROR_TIMEOUT, response.text()).then(function (message) { return Promise.reject({ response: response, message: message }); }, function () { return Promise.reject({ response: response }); });
|
|
46
47
|
}
|
|
47
48
|
latencyTracker();
|
|
48
49
|
return response;
|
|
@@ -50,8 +50,8 @@ export { AbstractSplitsCacheSync };
|
|
|
50
50
|
* Given a parsed split, it returns a boolean flagging if its conditions use segments matchers (rules & whitelists).
|
|
51
51
|
* This util is intended to simplify the implementation of `splitsCache::usesSegments` method
|
|
52
52
|
*/
|
|
53
|
-
export function usesSegments(
|
|
54
|
-
var conditions =
|
|
53
|
+
export function usesSegments(split) {
|
|
54
|
+
var conditions = split.conditions || [];
|
|
55
55
|
for (var i = 0; i < conditions.length; i++) {
|
|
56
56
|
var matchers = conditions[i].matcherGroup.matchers;
|
|
57
57
|
for (var j = 0; j < matchers.length; j++) {
|
|
@@ -60,8 +60,5 @@ export function usesSegments(ruleEntity) {
|
|
|
60
60
|
return true;
|
|
61
61
|
}
|
|
62
62
|
}
|
|
63
|
-
var excluded = ruleEntity.excluded;
|
|
64
|
-
if (excluded && excluded.segments && excluded.segments.length > 0)
|
|
65
|
-
return true;
|
|
66
63
|
return false;
|
|
67
64
|
}
|
|
@@ -24,15 +24,6 @@ var KeyBuilder = /** @class */ (function () {
|
|
|
24
24
|
KeyBuilder.prototype.buildSplitKeyPrefix = function () {
|
|
25
25
|
return this.prefix + ".split.";
|
|
26
26
|
};
|
|
27
|
-
KeyBuilder.prototype.buildRBSegmentKey = function (rbsegmentName) {
|
|
28
|
-
return this.prefix + ".rbsegment." + rbsegmentName;
|
|
29
|
-
};
|
|
30
|
-
KeyBuilder.prototype.buildRBSegmentsTillKey = function () {
|
|
31
|
-
return this.prefix + ".rbsegments.till";
|
|
32
|
-
};
|
|
33
|
-
KeyBuilder.prototype.buildRBSegmentKeyPrefix = function () {
|
|
34
|
-
return this.prefix + ".rbsegment.";
|
|
35
|
-
};
|
|
36
27
|
KeyBuilder.prototype.buildSegmentNameKey = function (segmentName) {
|
|
37
28
|
return this.prefix + ".segment." + segmentName;
|
|
38
29
|
};
|
|
@@ -32,9 +32,6 @@ var KeyBuilderCS = /** @class */ (function (_super) {
|
|
|
32
32
|
KeyBuilderCS.prototype.isSplitKey = function (key) {
|
|
33
33
|
return startsWith(key, this.prefix + ".split.");
|
|
34
34
|
};
|
|
35
|
-
KeyBuilderCS.prototype.isRBSegmentKey = function (key) {
|
|
36
|
-
return startsWith(key, this.prefix + ".rbsegment.");
|
|
37
|
-
};
|
|
38
35
|
KeyBuilderCS.prototype.buildSplitsWithSegmentCountKey = function () {
|
|
39
36
|
return this.prefix + ".splits.usingSegments";
|
|
40
37
|
};
|
|
@@ -39,9 +39,6 @@ var KeyBuilderSS = /** @class */ (function (_super) {
|
|
|
39
39
|
KeyBuilderSS.prototype.searchPatternForSplitKeys = function () {
|
|
40
40
|
return this.buildSplitKeyPrefix() + "*";
|
|
41
41
|
};
|
|
42
|
-
KeyBuilderSS.prototype.searchPatternForRBSegmentKeys = function () {
|
|
43
|
-
return this.buildRBSegmentKeyPrefix() + "*";
|
|
44
|
-
};
|
|
45
42
|
/* Telemetry keys */
|
|
46
43
|
KeyBuilderSS.prototype.buildLatencyKey = function (method, bucket) {
|
|
47
44
|
return this.latencyPrefix + "::" + this.versionablePrefix + "/" + METHOD_NAMES[method] + "/" + bucket;
|
|
@@ -38,13 +38,15 @@ var SplitsCacheInLocal = /** @class */ (function (_super) {
|
|
|
38
38
|
};
|
|
39
39
|
SplitsCacheInLocal.prototype._incrementCounts = function (split) {
|
|
40
40
|
try {
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
localStorage.setItem(ttKey, toNumber(localStorage.getItem(ttKey)) + 1);
|
|
44
|
-
if (usesSegments(split)) {
|
|
45
|
-
var segmentsCountKey = this.keys.buildSplitsWithSegmentCountKey();
|
|
41
|
+
if (split) {
|
|
42
|
+
var ttKey = this.keys.buildTrafficTypeKey(split.trafficTypeName);
|
|
46
43
|
// @ts-expect-error
|
|
47
|
-
localStorage.setItem(
|
|
44
|
+
localStorage.setItem(ttKey, toNumber(localStorage.getItem(ttKey)) + 1);
|
|
45
|
+
if (usesSegments(split)) {
|
|
46
|
+
var segmentsCountKey = this.keys.buildSplitsWithSegmentCountKey();
|
|
47
|
+
// @ts-expect-error
|
|
48
|
+
localStorage.setItem(segmentsCountKey, toNumber(localStorage.getItem(segmentsCountKey)) + 1);
|
|
49
|
+
}
|
|
48
50
|
}
|
|
49
51
|
}
|
|
50
52
|
catch (e) {
|
|
@@ -153,9 +155,12 @@ var SplitsCacheInLocal = /** @class */ (function (_super) {
|
|
|
153
155
|
return true;
|
|
154
156
|
var storedCount = localStorage.getItem(this.keys.buildSplitsWithSegmentCountKey());
|
|
155
157
|
var splitsWithSegmentsCount = storedCount === null ? 0 : toNumber(storedCount);
|
|
156
|
-
|
|
157
|
-
splitsWithSegmentsCount > 0
|
|
158
|
-
|
|
158
|
+
if (isFiniteNumber(splitsWithSegmentsCount)) {
|
|
159
|
+
return splitsWithSegmentsCount > 0;
|
|
160
|
+
}
|
|
161
|
+
else {
|
|
162
|
+
return true;
|
|
163
|
+
}
|
|
159
164
|
};
|
|
160
165
|
SplitsCacheInLocal.prototype.getNamesByFlagSets = function (flagSets) {
|
|
161
166
|
var _this = this;
|
|
@@ -5,7 +5,6 @@ import { validatePrefix } from '../KeyBuilder';
|
|
|
5
5
|
import { KeyBuilderCS, myLargeSegmentsKeyBuilder } from '../KeyBuilderCS';
|
|
6
6
|
import { isLocalStorageAvailable } from '../../utils/env/isLocalStorageAvailable';
|
|
7
7
|
import { SplitsCacheInLocal } from './SplitsCacheInLocal';
|
|
8
|
-
import { RBSegmentsCacheInLocal } from './RBSegmentsCacheInLocal';
|
|
9
8
|
import { MySegmentsCacheInLocal } from './MySegmentsCacheInLocal';
|
|
10
9
|
import { InMemoryStorageCSFactory } from '../inMemory/InMemoryStorageCS';
|
|
11
10
|
import { LOG_PREFIX } from './constants';
|
|
@@ -30,12 +29,10 @@ export function InLocalStorage(options) {
|
|
|
30
29
|
var matchingKey = getMatching(settings.core.key);
|
|
31
30
|
var keys = new KeyBuilderCS(prefix, matchingKey);
|
|
32
31
|
var splits = new SplitsCacheInLocal(settings, keys);
|
|
33
|
-
var rbSegments = new RBSegmentsCacheInLocal(settings, keys);
|
|
34
32
|
var segments = new MySegmentsCacheInLocal(log, keys);
|
|
35
33
|
var largeSegments = new MySegmentsCacheInLocal(log, myLargeSegmentsKeyBuilder(prefix, matchingKey));
|
|
36
34
|
return {
|
|
37
35
|
splits: splits,
|
|
38
|
-
rbSegments: rbSegments,
|
|
39
36
|
segments: segments,
|
|
40
37
|
largeSegments: largeSegments,
|
|
41
38
|
impressions: new ImpressionsCacheInMemory(impressionsQueueSize),
|
|
@@ -44,14 +41,13 @@ export function InLocalStorage(options) {
|
|
|
44
41
|
telemetry: shouldRecordTelemetry(params) ? new TelemetryCacheInMemory(splits, segments) : undefined,
|
|
45
42
|
uniqueKeys: new UniqueKeysCacheInMemoryCS(),
|
|
46
43
|
validateCache: function () {
|
|
47
|
-
return validateCache(options, settings, keys, splits,
|
|
44
|
+
return validateCache(options, settings, keys, splits, segments, largeSegments);
|
|
48
45
|
},
|
|
49
46
|
destroy: function () { },
|
|
50
47
|
// When using shared instantiation with MEMORY we reuse everything but segments (they are customer per key).
|
|
51
48
|
shared: function (matchingKey) {
|
|
52
49
|
return {
|
|
53
50
|
splits: this.splits,
|
|
54
|
-
rbSegments: this.rbSegments,
|
|
55
51
|
segments: new MySegmentsCacheInLocal(log, new KeyBuilderCS(prefix, matchingKey)),
|
|
56
52
|
largeSegments: new MySegmentsCacheInLocal(log, myLargeSegmentsKeyBuilder(prefix, matchingKey)),
|
|
57
53
|
impressions: this.impressions,
|
|
@@ -54,12 +54,11 @@ function validateExpiration(options, settings, keys, currentTimestamp, isThereCa
|
|
|
54
54
|
*
|
|
55
55
|
* @returns `true` if cache is ready to be used, `false` otherwise (cache was cleared or there is no cache)
|
|
56
56
|
*/
|
|
57
|
-
export function validateCache(options, settings, keys, splits,
|
|
57
|
+
export function validateCache(options, settings, keys, splits, segments, largeSegments) {
|
|
58
58
|
var currentTimestamp = Date.now();
|
|
59
59
|
var isThereCache = splits.getChangeNumber() > -1;
|
|
60
60
|
if (validateExpiration(options, settings, keys, currentTimestamp, isThereCache)) {
|
|
61
61
|
splits.clear();
|
|
62
|
-
rbSegments.clear();
|
|
63
62
|
segments.clear();
|
|
64
63
|
largeSegments.clear();
|
|
65
64
|
// Update last clear timestamp
|
|
@@ -6,7 +6,6 @@ import { ImpressionCountsCacheInMemory } from './ImpressionCountsCacheInMemory';
|
|
|
6
6
|
import { LOCALHOST_MODE, STORAGE_MEMORY } from '../../utils/constants';
|
|
7
7
|
import { shouldRecordTelemetry, TelemetryCacheInMemory } from './TelemetryCacheInMemory';
|
|
8
8
|
import { UniqueKeysCacheInMemory } from './UniqueKeysCacheInMemory';
|
|
9
|
-
import { RBSegmentsCacheInMemory } from './RBSegmentsCacheInMemory';
|
|
10
9
|
/**
|
|
11
10
|
* InMemory storage factory for standalone server-side SplitFactory
|
|
12
11
|
*
|
|
@@ -15,11 +14,9 @@ import { RBSegmentsCacheInMemory } from './RBSegmentsCacheInMemory';
|
|
|
15
14
|
export function InMemoryStorageFactory(params) {
|
|
16
15
|
var _a = params.settings, _b = _a.scheduler, impressionsQueueSize = _b.impressionsQueueSize, eventsQueueSize = _b.eventsQueueSize, __splitFiltersValidation = _a.sync.__splitFiltersValidation;
|
|
17
16
|
var splits = new SplitsCacheInMemory(__splitFiltersValidation);
|
|
18
|
-
var rbSegments = new RBSegmentsCacheInMemory();
|
|
19
17
|
var segments = new SegmentsCacheInMemory();
|
|
20
18
|
var storage = {
|
|
21
19
|
splits: splits,
|
|
22
|
-
rbSegments: rbSegments,
|
|
23
20
|
segments: segments,
|
|
24
21
|
impressions: new ImpressionsCacheInMemory(impressionsQueueSize),
|
|
25
22
|
impressionCounts: new ImpressionCountsCacheInMemory(),
|
|
@@ -6,7 +6,6 @@ import { ImpressionCountsCacheInMemory } from './ImpressionCountsCacheInMemory';
|
|
|
6
6
|
import { LOCALHOST_MODE, STORAGE_MEMORY } from '../../utils/constants';
|
|
7
7
|
import { shouldRecordTelemetry, TelemetryCacheInMemory } from './TelemetryCacheInMemory';
|
|
8
8
|
import { UniqueKeysCacheInMemoryCS } from './UniqueKeysCacheInMemoryCS';
|
|
9
|
-
import { RBSegmentsCacheInMemory } from './RBSegmentsCacheInMemory';
|
|
10
9
|
/**
|
|
11
10
|
* InMemory storage factory for standalone client-side SplitFactory
|
|
12
11
|
*
|
|
@@ -15,12 +14,10 @@ import { RBSegmentsCacheInMemory } from './RBSegmentsCacheInMemory';
|
|
|
15
14
|
export function InMemoryStorageCSFactory(params) {
|
|
16
15
|
var _a = params.settings, _b = _a.scheduler, impressionsQueueSize = _b.impressionsQueueSize, eventsQueueSize = _b.eventsQueueSize, __splitFiltersValidation = _a.sync.__splitFiltersValidation;
|
|
17
16
|
var splits = new SplitsCacheInMemory(__splitFiltersValidation);
|
|
18
|
-
var rbSegments = new RBSegmentsCacheInMemory();
|
|
19
17
|
var segments = new MySegmentsCacheInMemory();
|
|
20
18
|
var largeSegments = new MySegmentsCacheInMemory();
|
|
21
19
|
var storage = {
|
|
22
20
|
splits: splits,
|
|
23
|
-
rbSegments: rbSegments,
|
|
24
21
|
segments: segments,
|
|
25
22
|
largeSegments: largeSegments,
|
|
26
23
|
impressions: new ImpressionsCacheInMemory(impressionsQueueSize),
|
|
@@ -33,7 +30,6 @@ export function InMemoryStorageCSFactory(params) {
|
|
|
33
30
|
shared: function () {
|
|
34
31
|
return {
|
|
35
32
|
splits: this.splits,
|
|
36
|
-
rbSegments: this.rbSegments,
|
|
37
33
|
segments: new MySegmentsCacheInMemory(),
|
|
38
34
|
largeSegments: new MySegmentsCacheInMemory(),
|
|
39
35
|
impressions: this.impressions,
|
|
@@ -9,7 +9,6 @@ import { TelemetryCacheInRedis } from './TelemetryCacheInRedis';
|
|
|
9
9
|
import { UniqueKeysCacheInRedis } from './UniqueKeysCacheInRedis';
|
|
10
10
|
import { ImpressionCountsCacheInRedis } from './ImpressionCountsCacheInRedis';
|
|
11
11
|
import { metadataBuilder } from '../utils';
|
|
12
|
-
import { RBSegmentsCacheInRedis } from './RBSegmentsCacheInRedis';
|
|
13
12
|
var RD;
|
|
14
13
|
try {
|
|
15
14
|
// Using `require` to prevent error when bundling or importing the SDK in a .mjs file, since ioredis is a CommonJS module.
|
|
@@ -46,7 +45,6 @@ export function InRedisStorage(options) {
|
|
|
46
45
|
});
|
|
47
46
|
return {
|
|
48
47
|
splits: new SplitsCacheInRedis(log, keys, redisClient, settings.sync.__splitFiltersValidation),
|
|
49
|
-
rbSegments: new RBSegmentsCacheInRedis(log, keys, redisClient),
|
|
50
48
|
segments: new SegmentsCacheInRedis(log, keys, redisClient),
|
|
51
49
|
impressions: new ImpressionsCacheInRedis(log, keys.buildImpressionsKey(), redisClient, metadata),
|
|
52
50
|
impressionCounts: impressionCountsCache,
|
|
@@ -19,7 +19,6 @@ import { UniqueKeysCacheInMemory } from '../inMemory/UniqueKeysCacheInMemory';
|
|
|
19
19
|
import { UniqueKeysCacheInMemoryCS } from '../inMemory/UniqueKeysCacheInMemoryCS';
|
|
20
20
|
import { metadataBuilder } from '../utils';
|
|
21
21
|
import { LOG_PREFIX } from '../pluggable/constants';
|
|
22
|
-
import { RBSegmentsCachePluggable } from './RBSegmentsCachePluggable';
|
|
23
22
|
var NO_VALID_WRAPPER = 'Expecting pluggable storage `wrapper` in options, but no valid wrapper instance was provided.';
|
|
24
23
|
var NO_VALID_WRAPPER_INTERFACE = 'The provided wrapper instance doesn’t follow the expected interface. Check our docs.';
|
|
25
24
|
/**
|
|
@@ -103,7 +102,6 @@ export function PluggableStorage(options) {
|
|
|
103
102
|
});
|
|
104
103
|
return {
|
|
105
104
|
splits: new SplitsCachePluggable(log, keys, wrapper, settings.sync.__splitFiltersValidation),
|
|
106
|
-
rbSegments: new RBSegmentsCachePluggable(log, keys, wrapper),
|
|
107
105
|
segments: new SegmentsCachePluggable(log, keys, wrapper),
|
|
108
106
|
impressions: isPartialConsumer ? new ImpressionsCacheInMemory(impressionsQueueSize) : new ImpressionsCachePluggable(log, keys.buildImpressionsKey(), wrapper, metadata),
|
|
109
107
|
impressionCounts: impressionCountsCache,
|