@splitsoftware/splitio-commons 2.2.0 → 2.2.1-rc.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGES.txt +3 -0
- package/README.md +1 -0
- package/cjs/evaluator/combiners/and.js +2 -6
- package/cjs/evaluator/combiners/ifelseif.js +6 -6
- package/cjs/evaluator/condition/index.js +6 -5
- package/cjs/evaluator/index.js +7 -7
- package/cjs/evaluator/matchers/index.js +3 -1
- package/cjs/evaluator/matchers/matcherTypes.js +1 -0
- package/cjs/evaluator/matchers/rbsegment.js +44 -0
- package/cjs/evaluator/matchersTransform/index.js +4 -0
- package/cjs/evaluator/parser/index.js +2 -2
- package/cjs/evaluator/value/sanitize.js +1 -0
- package/cjs/logger/constants.js +4 -3
- package/cjs/logger/messages/debug.js +3 -2
- package/cjs/logger/messages/warn.js +1 -1
- package/cjs/services/splitApi.js +3 -4
- package/cjs/storages/AbstractSplitsCacheSync.js +5 -2
- package/cjs/storages/KeyBuilder.js +9 -0
- package/cjs/storages/KeyBuilderCS.js +3 -0
- package/cjs/storages/KeyBuilderSS.js +3 -0
- package/cjs/storages/inLocalStorage/RBSegmentsCacheInLocal.js +117 -0
- package/cjs/storages/inLocalStorage/SplitsCacheInLocal.js +9 -14
- package/cjs/storages/inLocalStorage/index.js +5 -1
- package/cjs/storages/inLocalStorage/validateCache.js +2 -1
- package/cjs/storages/inMemory/InMemoryStorage.js +3 -0
- package/cjs/storages/inMemory/InMemoryStorageCS.js +4 -0
- package/cjs/storages/inMemory/RBSegmentsCacheInMemory.js +61 -0
- package/cjs/storages/inRedis/RBSegmentsCacheInRedis.js +64 -0
- package/cjs/storages/inRedis/index.js +2 -0
- package/cjs/storages/pluggable/RBSegmentsCachePluggable.js +64 -0
- package/cjs/storages/pluggable/index.js +2 -0
- package/cjs/sync/polling/fetchers/splitChangesFetcher.js +51 -4
- 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 +51 -33
- package/cjs/sync/streaming/SSEHandler/index.js +1 -0
- package/cjs/sync/streaming/UpdateWorkers/SplitsUpdateWorker.js +106 -77
- package/cjs/sync/streaming/constants.js +2 -1
- package/cjs/sync/streaming/pushManager.js +3 -16
- package/cjs/sync/syncManagerOnline.js +2 -2
- package/cjs/utils/constants/index.js +3 -2
- package/esm/evaluator/combiners/and.js +2 -6
- package/esm/evaluator/combiners/ifelseif.js +7 -7
- package/esm/evaluator/condition/index.js +6 -5
- package/esm/evaluator/index.js +7 -7
- package/esm/evaluator/matchers/index.js +3 -1
- package/esm/evaluator/matchers/matcherTypes.js +1 -0
- package/esm/evaluator/matchers/rbsegment.js +40 -0
- package/esm/evaluator/matchersTransform/index.js +4 -0
- package/esm/evaluator/parser/index.js +2 -2
- package/esm/evaluator/value/sanitize.js +1 -0
- package/esm/logger/constants.js +1 -0
- package/esm/logger/messages/debug.js +3 -2
- package/esm/logger/messages/warn.js +1 -1
- package/esm/services/splitApi.js +3 -4
- package/esm/storages/AbstractSplitsCacheSync.js +5 -2
- package/esm/storages/KeyBuilder.js +9 -0
- package/esm/storages/KeyBuilderCS.js +3 -0
- package/esm/storages/KeyBuilderSS.js +3 -0
- package/esm/storages/inLocalStorage/RBSegmentsCacheInLocal.js +114 -0
- package/esm/storages/inLocalStorage/SplitsCacheInLocal.js +9 -14
- package/esm/storages/inLocalStorage/index.js +5 -1
- package/esm/storages/inLocalStorage/validateCache.js +2 -1
- package/esm/storages/inMemory/InMemoryStorage.js +3 -0
- package/esm/storages/inMemory/InMemoryStorageCS.js +4 -0
- package/esm/storages/inMemory/RBSegmentsCacheInMemory.js +58 -0
- package/esm/storages/inRedis/RBSegmentsCacheInRedis.js +61 -0
- package/esm/storages/inRedis/index.js +2 -0
- package/esm/storages/pluggable/RBSegmentsCachePluggable.js +61 -0
- package/esm/storages/pluggable/index.js +2 -0
- package/esm/sync/polling/fetchers/splitChangesFetcher.js +51 -4
- 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 +51 -33
- package/esm/sync/streaming/SSEHandler/index.js +2 -1
- package/esm/sync/streaming/UpdateWorkers/SplitsUpdateWorker.js +102 -73
- package/esm/sync/streaming/constants.js +1 -0
- package/esm/sync/streaming/pushManager.js +6 -19
- package/esm/sync/syncManagerOnline.js +2 -2
- package/esm/utils/constants/index.js +2 -1
- package/package.json +1 -1
- package/src/dtos/types.ts +32 -8
- package/src/evaluator/Engine.ts +1 -1
- package/src/evaluator/combiners/and.ts +5 -4
- package/src/evaluator/combiners/ifelseif.ts +7 -9
- 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 +3 -1
- package/src/evaluator/matchers/matcherTypes.ts +1 -0
- package/src/evaluator/matchers/rbsegment.ts +62 -0
- package/src/evaluator/matchersTransform/index.ts +3 -0
- 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 +5 -4
- package/src/logger/constants.ts +1 -0
- package/src/logger/messages/debug.ts +3 -2
- package/src/logger/messages/warn.ts +1 -1
- package/src/sdkManager/index.ts +1 -1
- package/src/services/splitApi.ts +3 -4
- package/src/services/types.ts +1 -1
- package/src/storages/AbstractSplitsCacheSync.ts +6 -3
- package/src/storages/KeyBuilder.ts +12 -0
- package/src/storages/KeyBuilderCS.ts +4 -0
- package/src/storages/KeyBuilderSS.ts +4 -0
- package/src/storages/inLocalStorage/RBSegmentsCacheInLocal.ts +136 -0
- package/src/storages/inLocalStorage/SplitsCacheInLocal.ts +10 -14
- package/src/storages/inLocalStorage/index.ts +5 -1
- package/src/storages/inLocalStorage/validateCache.ts +3 -1
- package/src/storages/inMemory/InMemoryStorage.ts +3 -0
- package/src/storages/inMemory/InMemoryStorageCS.ts +4 -0
- package/src/storages/inMemory/RBSegmentsCacheInMemory.ts +68 -0
- package/src/storages/inRedis/RBSegmentsCacheInRedis.ts +79 -0
- package/src/storages/inRedis/index.ts +2 -0
- package/src/storages/pluggable/RBSegmentsCachePluggable.ts +76 -0
- package/src/storages/pluggable/index.ts +2 -0
- package/src/storages/types.ts +33 -1
- package/src/sync/polling/fetchers/splitChangesFetcher.ts +62 -4
- package/src/sync/polling/fetchers/types.ts +1 -0
- 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 +61 -42
- package/src/sync/streaming/SSEHandler/index.ts +2 -1
- package/src/sync/streaming/SSEHandler/types.ts +2 -2
- package/src/sync/streaming/UpdateWorkers/SplitsUpdateWorker.ts +98 -68
- package/src/sync/streaming/constants.ts +1 -0
- package/src/sync/streaming/parseUtils.ts +2 -2
- package/src/sync/streaming/pushManager.ts +6 -18
- package/src/sync/streaming/types.ts +3 -2
- package/src/sync/syncManagerOnline.ts +2 -2
- package/src/utils/constants/index.ts +2 -1
- package/src/utils/lang/index.ts +1 -1
|
@@ -1,106 +1,135 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.SplitsUpdateWorker = void 0;
|
|
4
|
-
var constants_1 = require("../../../
|
|
4
|
+
var constants_1 = require("../../../logger/constants");
|
|
5
|
+
var constants_2 = require("../../../readiness/constants");
|
|
5
6
|
var Backoff_1 = require("../../../utils/Backoff");
|
|
6
|
-
var
|
|
7
|
-
var
|
|
7
|
+
var constants_3 = require("../../../utils/constants");
|
|
8
|
+
var constants_4 = require("../constants");
|
|
9
|
+
var parseUtils_1 = require("../parseUtils");
|
|
10
|
+
var constants_5 = require("./constants");
|
|
8
11
|
/**
|
|
9
12
|
* SplitsUpdateWorker factory
|
|
10
13
|
*/
|
|
11
|
-
function SplitsUpdateWorker(log,
|
|
12
|
-
var
|
|
13
|
-
var
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
if
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
if (splitUpdateNotification_1)
|
|
32
|
-
telemetryTracker.trackUpdatesFromSSE(constants_2.SPLITS);
|
|
33
|
-
// fetch new registered segments for server-side API. Not retrying on error
|
|
34
|
-
if (segmentsSyncTask)
|
|
35
|
-
segmentsSyncTask.execute(true);
|
|
36
|
-
var attempts = backoff.attempts + 1;
|
|
37
|
-
if (maxChangeNumber <= splitsCache.getChangeNumber()) {
|
|
38
|
-
log.debug("Refresh completed" + (cdnBypass ? ' bypassing the CDN' : '') + " in " + attempts + " attempts.");
|
|
39
|
-
isHandlingEvent = false;
|
|
40
|
-
return;
|
|
41
|
-
}
|
|
42
|
-
if (attempts < constants_3.FETCH_BACKOFF_MAX_RETRIES) {
|
|
43
|
-
backoff.scheduleCall();
|
|
44
|
-
return;
|
|
45
|
-
}
|
|
46
|
-
if (cdnBypass) {
|
|
47
|
-
log.debug("No changes fetched after " + attempts + " attempts with CDN bypassed.");
|
|
48
|
-
isHandlingEvent = false;
|
|
14
|
+
function SplitsUpdateWorker(log, storage, splitsSyncTask, splitsEventEmitter, telemetryTracker, segmentsSyncTask) {
|
|
15
|
+
var ff = SplitsUpdateWorker(storage.splits);
|
|
16
|
+
var rbs = SplitsUpdateWorker(storage.rbSegments);
|
|
17
|
+
function SplitsUpdateWorker(cache) {
|
|
18
|
+
var maxChangeNumber = -1;
|
|
19
|
+
var handleNewEvent = false;
|
|
20
|
+
var isHandlingEvent;
|
|
21
|
+
var cdnBypass;
|
|
22
|
+
var instantUpdate;
|
|
23
|
+
var backoff = new Backoff_1.Backoff(__handleSplitUpdateCall, constants_5.FETCH_BACKOFF_BASE, constants_5.FETCH_BACKOFF_MAX_WAIT);
|
|
24
|
+
function __handleSplitUpdateCall() {
|
|
25
|
+
isHandlingEvent = true;
|
|
26
|
+
if (maxChangeNumber > cache.getChangeNumber()) {
|
|
27
|
+
handleNewEvent = false;
|
|
28
|
+
// fetch splits revalidating data if cached
|
|
29
|
+
splitsSyncTask.execute(true, cdnBypass ? maxChangeNumber : undefined, instantUpdate).then(function () {
|
|
30
|
+
if (!isHandlingEvent)
|
|
31
|
+
return; // halt if `stop` has been called
|
|
32
|
+
if (handleNewEvent) {
|
|
33
|
+
__handleSplitUpdateCall();
|
|
49
34
|
}
|
|
50
35
|
else {
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
36
|
+
if (instantUpdate)
|
|
37
|
+
telemetryTracker.trackUpdatesFromSSE(constants_3.SPLITS);
|
|
38
|
+
// fetch new registered segments for server-side API. Not retrying on error
|
|
39
|
+
if (segmentsSyncTask)
|
|
40
|
+
segmentsSyncTask.execute(true);
|
|
41
|
+
var attempts = backoff.attempts + 1;
|
|
42
|
+
if (ff.isSync() && rbs.isSync()) {
|
|
43
|
+
log.debug("Refresh completed" + (cdnBypass ? ' bypassing the CDN' : '') + " in " + attempts + " attempts.");
|
|
44
|
+
isHandlingEvent = false;
|
|
45
|
+
return;
|
|
46
|
+
}
|
|
47
|
+
if (attempts < constants_5.FETCH_BACKOFF_MAX_RETRIES) {
|
|
48
|
+
backoff.scheduleCall();
|
|
49
|
+
return;
|
|
50
|
+
}
|
|
51
|
+
if (cdnBypass) {
|
|
52
|
+
log.debug("No changes fetched after " + attempts + " attempts with CDN bypassed.");
|
|
53
|
+
isHandlingEvent = false;
|
|
54
|
+
}
|
|
55
|
+
else {
|
|
56
|
+
backoff.reset();
|
|
57
|
+
cdnBypass = true;
|
|
58
|
+
__handleSplitUpdateCall();
|
|
59
|
+
}
|
|
54
60
|
}
|
|
55
|
-
}
|
|
56
|
-
}
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
}
|
|
61
|
-
}
|
|
62
|
-
/**
|
|
63
|
-
* Invoked by NotificationProcessor on SPLIT_UPDATE event
|
|
64
|
-
*
|
|
65
|
-
* @param changeNumber - change number of the SPLIT_UPDATE notification
|
|
66
|
-
*/
|
|
67
|
-
function put(_a, _payload) {
|
|
68
|
-
var changeNumber = _a.changeNumber, pcn = _a.pcn;
|
|
69
|
-
var currentChangeNumber = splitsCache.getChangeNumber();
|
|
70
|
-
if (changeNumber <= currentChangeNumber || changeNumber <= maxChangeNumber)
|
|
71
|
-
return;
|
|
72
|
-
maxChangeNumber = changeNumber;
|
|
73
|
-
handleNewEvent = true;
|
|
74
|
-
cdnBypass = false;
|
|
75
|
-
payload = undefined;
|
|
76
|
-
if (_payload && currentChangeNumber === pcn) {
|
|
77
|
-
payload = _payload;
|
|
61
|
+
});
|
|
62
|
+
}
|
|
63
|
+
else {
|
|
64
|
+
isHandlingEvent = false;
|
|
65
|
+
}
|
|
78
66
|
}
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
67
|
+
return {
|
|
68
|
+
/**
|
|
69
|
+
* Invoked by NotificationProcessor on SPLIT_UPDATE or RB_SEGMENT_UPDATE event
|
|
70
|
+
*
|
|
71
|
+
* @param changeNumber - change number of the notification
|
|
72
|
+
*/
|
|
73
|
+
put: function (_a, payload) {
|
|
74
|
+
var changeNumber = _a.changeNumber, pcn = _a.pcn, type = _a.type;
|
|
75
|
+
var currentChangeNumber = cache.getChangeNumber();
|
|
76
|
+
if (changeNumber <= currentChangeNumber || changeNumber <= maxChangeNumber)
|
|
77
|
+
return;
|
|
78
|
+
maxChangeNumber = changeNumber;
|
|
79
|
+
handleNewEvent = true;
|
|
80
|
+
cdnBypass = false;
|
|
81
|
+
instantUpdate = undefined;
|
|
82
|
+
if (payload && currentChangeNumber === pcn) {
|
|
83
|
+
instantUpdate = { payload: payload, changeNumber: changeNumber, type: type };
|
|
84
|
+
}
|
|
85
|
+
if (backoff.timeoutID || !isHandlingEvent)
|
|
86
|
+
__handleSplitUpdateCall();
|
|
87
|
+
backoff.reset();
|
|
88
|
+
},
|
|
89
|
+
stop: function () {
|
|
90
|
+
isHandlingEvent = false;
|
|
91
|
+
backoff.reset();
|
|
92
|
+
},
|
|
93
|
+
isSync: function () {
|
|
94
|
+
return maxChangeNumber <= cache.getChangeNumber();
|
|
95
|
+
}
|
|
96
|
+
};
|
|
82
97
|
}
|
|
83
98
|
return {
|
|
84
|
-
put:
|
|
99
|
+
put: function (parsedData) {
|
|
100
|
+
if (parsedData.d && parsedData.c !== undefined) {
|
|
101
|
+
try {
|
|
102
|
+
var payload = (0, parseUtils_1.parseFFUpdatePayload)(parsedData.c, parsedData.d);
|
|
103
|
+
if (payload) {
|
|
104
|
+
(parsedData.type === constants_4.RB_SEGMENT_UPDATE ? rbs : ff).put(parsedData, payload);
|
|
105
|
+
return;
|
|
106
|
+
}
|
|
107
|
+
}
|
|
108
|
+
catch (e) {
|
|
109
|
+
log.warn(constants_1.STREAMING_PARSING_SPLIT_UPDATE, [parsedData.type, e]);
|
|
110
|
+
}
|
|
111
|
+
}
|
|
112
|
+
(parsedData.type === constants_4.RB_SEGMENT_UPDATE ? rbs : ff).put(parsedData);
|
|
113
|
+
},
|
|
85
114
|
/**
|
|
86
115
|
* Invoked by NotificationProcessor on SPLIT_KILL event
|
|
87
116
|
*
|
|
88
|
-
* @param changeNumber - change number of the
|
|
117
|
+
* @param changeNumber - change number of the notification
|
|
89
118
|
* @param splitName - name of split to kill
|
|
90
119
|
* @param defaultTreatment - default treatment value
|
|
91
120
|
*/
|
|
92
121
|
killSplit: function (_a) {
|
|
93
122
|
var changeNumber = _a.changeNumber, splitName = _a.splitName, defaultTreatment = _a.defaultTreatment;
|
|
94
|
-
if (
|
|
123
|
+
if (storage.splits.killLocally(splitName, defaultTreatment, changeNumber)) {
|
|
95
124
|
// trigger an SDK_UPDATE if Split was killed locally
|
|
96
|
-
splitsEventEmitter.emit(
|
|
125
|
+
splitsEventEmitter.emit(constants_2.SDK_SPLITS_ARRIVED, true);
|
|
97
126
|
}
|
|
98
127
|
// queues the SplitChanges fetch (only if changeNumber is newer)
|
|
99
|
-
put({ changeNumber: changeNumber });
|
|
128
|
+
ff.put({ changeNumber: changeNumber });
|
|
100
129
|
},
|
|
101
130
|
stop: function () {
|
|
102
|
-
|
|
103
|
-
|
|
131
|
+
ff.stop();
|
|
132
|
+
rbs.stop();
|
|
104
133
|
}
|
|
105
134
|
};
|
|
106
135
|
}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
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;
|
|
3
|
+
exports.ControlType = exports.OCCUPANCY = exports.CONTROL = exports.RB_SEGMENT_UPDATE = 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,6 +30,7 @@ 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';
|
|
33
34
|
// Control-type push notifications, handled by NotificationKeeper
|
|
34
35
|
exports.CONTROL = 'CONTROL';
|
|
35
36
|
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
|
|
49
|
+
var splitsUpdateWorker = (0, SplitsUpdateWorker_1.SplitsUpdateWorker)(log, storage, 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,21 +182,8 @@ 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
|
-
|
|
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
|
-
});
|
|
185
|
+
pushEmitter.on(constants_1.SPLIT_UPDATE, splitsUpdateWorker.put);
|
|
186
|
+
pushEmitter.on(constants_1.RB_SEGMENT_UPDATE, splitsUpdateWorker.put);
|
|
200
187
|
function handleMySegmentsUpdate(parsedData) {
|
|
201
188
|
switch (parsedData.u) {
|
|
202
189
|
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() || storage.rbSegments.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() || storage.rbSegments.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.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;
|
|
4
|
+
exports.IN_RULE_BASED_SEGMENT = 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,7 +90,8 @@ 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.3';
|
|
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';
|
|
@@ -8,12 +8,8 @@ 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
|
|
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); });
|
|
11
|
+
return function andCombiner(key, attributes, splitEvaluator) {
|
|
12
|
+
var matcherResults = matchers.map(function (matcher) { return matcher(key, attributes, splitEvaluator); });
|
|
17
13
|
// If any matching result is a thenable we should use Promise.all
|
|
18
14
|
if (findIndex(matcherResults, thenable) !== -1) {
|
|
19
15
|
return Promise.all(matcherResults).then(andResults);
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { findIndex } from '../../utils/lang';
|
|
1
|
+
import { findIndex, isBoolean } 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
|
-
var len = predicateResults.length;
|
|
16
|
-
for (var i = 0; i < len; i++) {
|
|
14
|
+
function computeEvaluation(predicateResults) {
|
|
15
|
+
for (var i = 0, len = predicateResults.length; i < len; i++) {
|
|
17
16
|
var evaluation = predicateResults[i];
|
|
18
17
|
if (evaluation !== undefined) {
|
|
19
|
-
|
|
18
|
+
if (!isBoolean(evaluation))
|
|
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 computeEvaluation(results); });
|
|
34
34
|
}
|
|
35
|
-
return
|
|
35
|
+
return computeEvaluation(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,11 +4,12 @@ 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
|
-
|
|
7
|
+
return treatments ? // Feature flag
|
|
8
|
+
{
|
|
9
|
+
treatment: getTreatment(log, bucketingKey, seed, treatments),
|
|
10
|
+
label: label
|
|
11
|
+
} : // Rule-based segment
|
|
12
|
+
true;
|
|
12
13
|
}
|
|
13
14
|
// else we should notify the engine to continue evaluating
|
|
14
15
|
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, key, split, 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, key, parsedSplit, 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, splitNames, splits,
|
|
46
|
+
parsedSplits.then(function (splits) { return getEvaluations(log, key, splitNames, splits, 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, splitNames, parsedSplits,
|
|
52
|
+
getEvaluations(log, key, splitNames, parsedSplits, 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, key, splitJSON, attributes, storage) {
|
|
88
88
|
var evaluation = {
|
|
89
89
|
treatment: CONTROL,
|
|
90
90
|
label: SPLIT_NOT_FOUND,
|
|
@@ -110,11 +110,11 @@ function getEvaluation(log, splitJSON, key, attributes, storage) {
|
|
|
110
110
|
}
|
|
111
111
|
return evaluation;
|
|
112
112
|
}
|
|
113
|
-
function getEvaluations(log, splitNames, splits,
|
|
113
|
+
function getEvaluations(log, key, splitNames, splits, attributes, storage) {
|
|
114
114
|
var result = {};
|
|
115
115
|
var thenables = [];
|
|
116
116
|
splitNames.forEach(function (splitName) {
|
|
117
|
-
var evaluation = getEvaluation(log, splits[splitName],
|
|
117
|
+
var evaluation = getEvaluation(log, key, splits[splitName], attributes, storage);
|
|
118
118
|
if (thenable(evaluation)) {
|
|
119
119
|
thenables.push(evaluation.then(function (res) {
|
|
120
120
|
result[splitName] = res;
|
|
@@ -21,6 +21,7 @@ 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';
|
|
24
25
|
var matchers = [
|
|
25
26
|
undefined,
|
|
26
27
|
allMatcherContext,
|
|
@@ -45,7 +46,8 @@ var matchers = [
|
|
|
45
46
|
lessThanEqualToSemverMatcherContext,
|
|
46
47
|
betweenSemverMatcherContext,
|
|
47
48
|
inListSemverMatcherContext,
|
|
48
|
-
largeSegmentMatcherContext,
|
|
49
|
+
largeSegmentMatcherContext,
|
|
50
|
+
ruleBasedSegmentMatcherContext // IN_RULE_BASED_SEGMENT: 24
|
|
49
51
|
];
|
|
50
52
|
/**
|
|
51
53
|
* Matcher factory.
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import { thenable } from '../../utils/promise/thenable';
|
|
2
|
+
import { getMatching, keyParser } from '../../utils/key';
|
|
3
|
+
import { parser } from '../parser';
|
|
4
|
+
export function ruleBasedSegmentMatcherContext(segmentName, storage, log) {
|
|
5
|
+
return function ruleBasedSegmentMatcher(_a, splitEvaluator) {
|
|
6
|
+
var key = _a.key, attributes = _a.attributes;
|
|
7
|
+
function matchConditions(rbsegment) {
|
|
8
|
+
var conditions = rbsegment.conditions || [];
|
|
9
|
+
var evaluator = parser(log, conditions, storage);
|
|
10
|
+
var evaluation = evaluator(keyParser(key), undefined, undefined, undefined, attributes, splitEvaluator);
|
|
11
|
+
return thenable(evaluation) ?
|
|
12
|
+
evaluation.then(function (evaluation) { return evaluation ? true : false; }) :
|
|
13
|
+
evaluation ? true : false;
|
|
14
|
+
}
|
|
15
|
+
function isExcluded(rbSegment) {
|
|
16
|
+
var matchingKey = getMatching(key);
|
|
17
|
+
var excluded = rbSegment.excluded || {};
|
|
18
|
+
if (excluded.keys && excluded.keys.indexOf(matchingKey) !== -1)
|
|
19
|
+
return true;
|
|
20
|
+
var isInSegment = (excluded.segments || []).map(function (segmentName) {
|
|
21
|
+
return storage.segments.isInSegment(segmentName, matchingKey);
|
|
22
|
+
});
|
|
23
|
+
return isInSegment.length && thenable(isInSegment[0]) ?
|
|
24
|
+
Promise.all(isInSegment).then(function (results) { return results.some(function (result) { return result; }); }) :
|
|
25
|
+
isInSegment.some(function (result) { return result; });
|
|
26
|
+
}
|
|
27
|
+
function isInSegment(rbSegment) {
|
|
28
|
+
if (!rbSegment)
|
|
29
|
+
return false;
|
|
30
|
+
var excluded = isExcluded(rbSegment);
|
|
31
|
+
return thenable(excluded) ?
|
|
32
|
+
excluded.then(function (excluded) { return excluded ? false : matchConditions(rbSegment); }) :
|
|
33
|
+
excluded ? false : matchConditions(rbSegment);
|
|
34
|
+
}
|
|
35
|
+
var rbSegment = storage.rbSegments.get(segmentName);
|
|
36
|
+
return thenable(rbSegment) ?
|
|
37
|
+
rbSegment.then(isInSegment) :
|
|
38
|
+
isInSegment(rbSegment);
|
|
39
|
+
};
|
|
40
|
+
}
|
|
@@ -78,6 +78,10 @@ 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
|
+
}
|
|
81
85
|
return {
|
|
82
86
|
attribute: attribute,
|
|
83
87
|
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), Treatments.parse(partitions), label, conditionType));
|
|
53
|
+
predicates.push(conditionContext(log, andCombinerContext(log, expressions), partitions && Treatments.parse(partitions), label, conditionType));
|
|
54
54
|
}
|
|
55
|
-
//
|
|
55
|
+
// Instantiate evaluator given the set of conditions using if else if logic
|
|
56
56
|
return ifElseIfCombinerContext(log, predicates);
|
|
57
57
|
}
|
|
@@ -49,6 +49,7 @@ 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:
|
|
52
53
|
return dependencyProcessor;
|
|
53
54
|
default:
|
|
54
55
|
return undefined;
|
package/esm/logger/constants.js
CHANGED
|
@@ -21,6 +21,7 @@ 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;
|
|
24
25
|
export var STREAMING_NEW_MESSAGE = 35;
|
|
25
26
|
export var SYNC_TASK_START = 36;
|
|
26
27
|
export var SYNC_TASK_EXECUTE = 37;
|
|
@@ -19,8 +19,9 @@ 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.
|
|
22
|
+
[c.SYNC_SPLITS_FETCH, c.LOG_PREFIX_SYNC_SPLITS + 'Spin up feature flags update using since = %s and rbSince = %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.'],
|
|
24
25
|
[c.STREAMING_NEW_MESSAGE, c.LOG_PREFIX_SYNC_STREAMING + 'New SSE message received, with data: %s.'],
|
|
25
26
|
[c.SYNC_TASK_START, c.LOG_PREFIX_SYNC + ': Starting %s. Running each %s millis'],
|
|
26
27
|
[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 %s 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,7 +17,6 @@ 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;
|
|
21
20
|
var splitHttpClient = splitHttpClientFactory(settings, platform);
|
|
22
21
|
return {
|
|
23
22
|
// @TODO throw errors if health check requests fail, to log them in the Synchronizer
|
|
@@ -30,7 +29,7 @@ export function splitApiFactory(settings, platform, telemetryTracker) {
|
|
|
30
29
|
return splitHttpClient(url).then(function () { return true; }).catch(function () { return false; });
|
|
31
30
|
},
|
|
32
31
|
fetchAuth: function (userMatchingKeys) {
|
|
33
|
-
var url = urls.auth + "/v2/auth?s=" + flagSpecVersion;
|
|
32
|
+
var url = urls.auth + "/v2/auth?s=" + settings.sync.flagSpecVersion;
|
|
34
33
|
if (userMatchingKeys) { // `userMatchingKeys` is undefined in server-side
|
|
35
34
|
var queryParams = userMatchingKeys.map(userKeyToQueryParam).join('&');
|
|
36
35
|
if (queryParams)
|
|
@@ -38,8 +37,8 @@ export function splitApiFactory(settings, platform, telemetryTracker) {
|
|
|
38
37
|
}
|
|
39
38
|
return splitHttpClient(url, undefined, telemetryTracker.trackHttp(TOKEN));
|
|
40
39
|
},
|
|
41
|
-
fetchSplitChanges: function (since, noCache, till) {
|
|
42
|
-
var url = urls.sdk + "/splitChanges?s=" + flagSpecVersion + "&since=" + since + (filterQueryString || '') + (till ? '&till=' + till : '');
|
|
40
|
+
fetchSplitChanges: function (since, noCache, till, rbSince) {
|
|
41
|
+
var url = urls.sdk + "/splitChanges?s=" + settings.sync.flagSpecVersion + "&since=" + since + (rbSince ? '&rbSince=' + rbSince : '') + (filterQueryString || '') + (till ? '&till=' + till : '');
|
|
43
42
|
return splitHttpClient(url, noCache ? noCacheHeaderOptions : undefined, telemetryTracker.trackHttp(SPLITS))
|
|
44
43
|
.catch(function (err) {
|
|
45
44
|
if (err.statusCode === 414)
|
|
@@ -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(ruleEntity) {
|
|
54
|
+
var conditions = ruleEntity.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,5 +60,8 @@ export function usesSegments(split) {
|
|
|
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;
|
|
63
66
|
return false;
|
|
64
67
|
}
|
|
@@ -24,6 +24,15 @@ 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
|
+
};
|
|
27
36
|
KeyBuilder.prototype.buildSegmentNameKey = function (segmentName) {
|
|
28
37
|
return this.prefix + ".segment." + segmentName;
|
|
29
38
|
};
|