@splitsoftware/splitio-commons 1.16.1-rc.1 → 1.16.1-rc.11
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 +4 -0
- package/cjs/logger/constants.js +5 -4
- package/cjs/logger/messages/info.js +2 -1
- package/cjs/logger/messages/warn.js +1 -1
- package/cjs/readiness/readinessManager.js +7 -12
- package/cjs/services/splitApi.js +5 -9
- package/cjs/storages/AbstractSegmentsCacheSync.js +41 -12
- package/cjs/storages/AbstractSplitsCacheAsync.js +2 -2
- package/cjs/storages/AbstractSplitsCacheSync.js +7 -5
- package/cjs/storages/KeyBuilder.js +0 -3
- package/cjs/storages/KeyBuilderCS.js +6 -0
- package/cjs/storages/dataLoader.js +1 -1
- package/cjs/storages/inLocalStorage/MySegmentsCacheInLocal.js +29 -52
- package/cjs/storages/inLocalStorage/SplitsCacheInLocal.js +4 -16
- package/cjs/storages/inMemory/MySegmentsCacheInMemory.js +9 -40
- package/cjs/storages/inMemory/SplitsCacheInMemory.js +6 -15
- package/cjs/sync/polling/fetchers/mySegmentsFetcher.js +4 -11
- package/cjs/sync/polling/fetchers/segmentChangesFetcher.js +1 -1
- package/cjs/sync/polling/pollingManagerCS.js +33 -51
- package/cjs/sync/polling/syncTasks/mySegmentsSyncTask.js +2 -2
- package/cjs/sync/polling/updaters/mySegmentsUpdater.js +14 -20
- package/cjs/sync/streaming/AuthClient/index.js +1 -1
- package/cjs/sync/streaming/SSEHandler/index.js +3 -6
- package/cjs/sync/streaming/UpdateWorkers/MySegmentsUpdateWorker.js +15 -9
- package/cjs/sync/streaming/constants.js +3 -4
- package/cjs/sync/streaming/parseUtils.js +14 -9
- package/cjs/sync/streaming/pushManager.js +29 -55
- package/cjs/sync/submitters/telemetrySubmitter.js +0 -2
- package/cjs/sync/syncManagerOnline.js +14 -24
- package/cjs/utils/constants/index.js +4 -5
- package/cjs/utils/settingsValidation/index.js +1 -5
- package/esm/logger/constants.js +2 -1
- package/esm/logger/messages/info.js +2 -1
- package/esm/logger/messages/warn.js +1 -1
- package/esm/readiness/readinessManager.js +7 -12
- package/esm/services/splitApi.js +6 -10
- package/esm/storages/AbstractSegmentsCacheSync.js +41 -12
- package/esm/storages/AbstractSplitsCacheAsync.js +2 -2
- package/esm/storages/AbstractSplitsCacheSync.js +5 -3
- package/esm/storages/KeyBuilder.js +0 -3
- package/esm/storages/KeyBuilderCS.js +6 -0
- package/esm/storages/dataLoader.js +1 -1
- package/esm/storages/inLocalStorage/MySegmentsCacheInLocal.js +29 -52
- package/esm/storages/inLocalStorage/SplitsCacheInLocal.js +5 -17
- package/esm/storages/inMemory/MySegmentsCacheInMemory.js +9 -40
- package/esm/storages/inMemory/SplitsCacheInMemory.js +7 -16
- package/esm/sync/polling/fetchers/mySegmentsFetcher.js +4 -11
- package/esm/sync/polling/fetchers/segmentChangesFetcher.js +1 -1
- package/esm/sync/polling/pollingManagerCS.js +34 -52
- package/esm/sync/polling/syncTasks/mySegmentsSyncTask.js +2 -2
- package/esm/sync/polling/updaters/mySegmentsUpdater.js +12 -18
- package/esm/sync/streaming/AuthClient/index.js +1 -1
- package/esm/sync/streaming/SSEHandler/index.js +4 -7
- package/esm/sync/streaming/UpdateWorkers/MySegmentsUpdateWorker.js +15 -9
- package/esm/sync/streaming/constants.js +2 -3
- package/esm/sync/streaming/parseUtils.js +12 -8
- package/esm/sync/streaming/pushManager.js +32 -57
- package/esm/sync/submitters/telemetrySubmitter.js +0 -2
- package/esm/sync/syncManagerOnline.js +15 -25
- package/esm/utils/constants/index.js +2 -3
- package/esm/utils/settingsValidation/index.js +1 -5
- package/package.json +1 -1
- package/src/dtos/types.ts +7 -8
- package/src/logger/constants.ts +2 -1
- package/src/logger/messages/info.ts +2 -1
- package/src/logger/messages/warn.ts +1 -1
- package/src/readiness/readinessManager.ts +7 -9
- package/src/readiness/types.ts +0 -1
- package/src/services/splitApi.ts +7 -12
- package/src/services/splitHttpClient.ts +1 -1
- package/src/services/types.ts +2 -3
- package/src/storages/AbstractSegmentsCacheSync.ts +53 -12
- package/src/storages/AbstractSplitsCacheAsync.ts +2 -2
- package/src/storages/AbstractSplitsCacheSync.ts +7 -5
- package/src/storages/KeyBuilder.ts +0 -3
- package/src/storages/KeyBuilderCS.ts +9 -0
- package/src/storages/dataLoader.ts +1 -1
- package/src/storages/inLocalStorage/MySegmentsCacheInLocal.ts +26 -56
- package/src/storages/inLocalStorage/SplitsCacheInLocal.ts +5 -20
- package/src/storages/inMemory/MySegmentsCacheInMemory.ts +10 -44
- package/src/storages/inMemory/SplitsCacheInMemory.ts +7 -13
- package/src/storages/types.ts +10 -8
- package/src/sync/polling/fetchers/mySegmentsFetcher.ts +7 -14
- package/src/sync/polling/fetchers/segmentChangesFetcher.ts +1 -1
- package/src/sync/polling/fetchers/types.ts +2 -2
- package/src/sync/polling/pollingManagerCS.ts +29 -61
- package/src/sync/polling/syncTasks/mySegmentsSyncTask.ts +12 -13
- package/src/sync/polling/types.ts +8 -8
- package/src/sync/polling/updaters/mySegmentsUpdater.ts +17 -18
- package/src/sync/streaming/AuthClient/index.ts +1 -1
- package/src/sync/streaming/SSEClient/index.ts +4 -6
- package/src/sync/streaming/SSEHandler/index.ts +5 -9
- package/src/sync/streaming/SSEHandler/types.ts +13 -25
- package/src/sync/streaming/UpdateWorkers/MySegmentsUpdateWorker.ts +17 -12
- package/src/sync/streaming/UpdateWorkers/SegmentsUpdateWorker.ts +1 -1
- package/src/sync/streaming/UpdateWorkers/SplitsUpdateWorker.ts +1 -1
- package/src/sync/streaming/UpdateWorkers/types.ts +2 -2
- package/src/sync/streaming/constants.ts +2 -3
- package/src/sync/streaming/parseUtils.ts +19 -11
- package/src/sync/streaming/pushManager.ts +38 -68
- package/src/sync/streaming/types.ts +11 -13
- package/src/sync/submitters/telemetrySubmitter.ts +0 -2
- package/src/sync/submitters/types.ts +3 -6
- package/src/sync/syncManagerOnline.ts +11 -19
- package/src/types.ts +1 -26
- package/src/utils/constants/index.ts +2 -3
- package/src/utils/settingsValidation/index.ts +1 -5
- package/types/dtos/types.d.ts +7 -8
- package/types/logger/constants.d.ts +2 -1
- package/types/readiness/types.d.ts +0 -1
- package/types/services/decorateHeaders.d.ts +2 -0
- package/types/services/splitApi.d.ts +1 -1
- package/types/services/splitHttpClient.d.ts +1 -1
- package/types/services/types.d.ts +2 -3
- package/types/storages/AbstractSegmentsCacheSync.d.ts +9 -11
- package/types/storages/AbstractSplitsCacheAsync.d.ts +1 -1
- package/types/storages/AbstractSplitsCacheSync.d.ts +4 -4
- package/types/storages/KeyBuilder.d.ts +0 -1
- package/types/storages/KeyBuilderCS.d.ts +2 -0
- package/types/storages/inLocalStorage/MySegmentsCacheInLocal.d.ts +2 -12
- package/types/storages/inLocalStorage/SplitsCacheInLocal.d.ts +1 -1
- package/types/storages/inMemory/MySegmentsCacheInMemory.d.ts +3 -9
- package/types/storages/inMemory/SplitsCacheInMemory.d.ts +1 -2
- package/types/storages/types.d.ts +8 -7
- package/types/sync/polling/fetchers/mySegmentsFetcher.d.ts +2 -2
- package/types/sync/polling/fetchers/types.d.ts +2 -2
- package/types/sync/polling/syncTasks/mySegmentsSyncTask.d.ts +4 -3
- package/types/sync/polling/types.d.ts +8 -12
- package/types/sync/polling/updaters/mySegmentsUpdater.d.ts +3 -2
- package/types/sync/streaming/SSEHandler/types.d.ts +13 -22
- package/types/sync/streaming/UpdateWorkers/MySegmentsUpdateWorker.d.ts +2 -3
- package/types/sync/streaming/UpdateWorkers/SegmentsUpdateWorker.d.ts +2 -1
- package/types/sync/streaming/UpdateWorkers/SplitsUpdateWorker.d.ts +3 -2
- package/types/sync/streaming/UpdateWorkers/types.d.ts +2 -2
- package/types/sync/streaming/constants.d.ts +2 -3
- package/types/sync/streaming/parseUtils.d.ts +4 -5
- package/types/sync/streaming/pushManager.d.ts +0 -2
- package/types/sync/streaming/pushManagerCS_Spec1_3.d.ts +9 -0
- package/types/sync/streaming/pushManager_Spec1_3.d.ts +9 -0
- package/types/sync/streaming/types.d.ts +9 -10
- package/types/sync/submitters/types.d.ts +3 -6
- package/types/types.d.ts +0 -25
- package/types/utils/constants/index.d.ts +2 -3
- package/types/utils/settingsValidation/index.d.ts +0 -2
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { __extends } from "tslib";
|
|
2
|
+
import { isNaNNumber } from '../../utils/lang';
|
|
2
3
|
import { AbstractSegmentsCacheSync } from '../AbstractSegmentsCacheSync';
|
|
3
4
|
import { LOG_PREFIX, DEFINED } from './constants';
|
|
4
5
|
var MySegmentsCacheInLocal = /** @class */ (function (_super) {
|
|
@@ -10,19 +11,11 @@ var MySegmentsCacheInLocal = /** @class */ (function (_super) {
|
|
|
10
11
|
return _this;
|
|
11
12
|
// There is not need to flush segments cache like splits cache, since resetSegments receives the up-to-date list of active segments
|
|
12
13
|
}
|
|
13
|
-
/**
|
|
14
|
-
* Removes list of segments from localStorage
|
|
15
|
-
* @NOTE this method is not being used at the moment.
|
|
16
|
-
*/
|
|
17
|
-
MySegmentsCacheInLocal.prototype.clear = function () {
|
|
18
|
-
this.log.info(LOG_PREFIX + 'Flushing MySegments data from localStorage');
|
|
19
|
-
// We cannot simply call `localStorage.clear()` since that implies removing user items from the storage
|
|
20
|
-
// We could optimize next sentence, since it implies iterating over all localStorage items
|
|
21
|
-
this.resetSegments([]);
|
|
22
|
-
};
|
|
23
14
|
MySegmentsCacheInLocal.prototype.addToSegment = function (name) {
|
|
24
15
|
var segmentKey = this.keys.buildSegmentNameKey(name);
|
|
25
16
|
try {
|
|
17
|
+
if (localStorage.getItem(segmentKey) === DEFINED)
|
|
18
|
+
return false;
|
|
26
19
|
localStorage.setItem(segmentKey, DEFINED);
|
|
27
20
|
return true;
|
|
28
21
|
}
|
|
@@ -34,6 +27,8 @@ var MySegmentsCacheInLocal = /** @class */ (function (_super) {
|
|
|
34
27
|
MySegmentsCacheInLocal.prototype.removeFromSegment = function (name) {
|
|
35
28
|
var segmentKey = this.keys.buildSegmentNameKey(name);
|
|
36
29
|
try {
|
|
30
|
+
if (localStorage.getItem(segmentKey) !== DEFINED)
|
|
31
|
+
return false;
|
|
37
32
|
localStorage.removeItem(segmentKey);
|
|
38
33
|
return true;
|
|
39
34
|
}
|
|
@@ -45,30 +40,22 @@ var MySegmentsCacheInLocal = /** @class */ (function (_super) {
|
|
|
45
40
|
MySegmentsCacheInLocal.prototype.isInSegment = function (name) {
|
|
46
41
|
return localStorage.getItem(this.keys.buildSegmentNameKey(name)) === DEFINED;
|
|
47
42
|
};
|
|
48
|
-
|
|
49
|
-
* Reset (update) the cached list of segments with the given list, removing and adding segments if necessary.
|
|
50
|
-
*
|
|
51
|
-
* @param {string[]} segmentNames list of segment names
|
|
52
|
-
* @returns boolean indicating if the cache was updated (i.e., given list was different from the cached one)
|
|
53
|
-
*/
|
|
54
|
-
MySegmentsCacheInLocal.prototype.resetSegments = function (names) {
|
|
43
|
+
MySegmentsCacheInLocal.prototype.getRegisteredSegments = function () {
|
|
55
44
|
var _this = this;
|
|
56
|
-
var isDiff = false;
|
|
57
|
-
var index;
|
|
58
45
|
// Scan current values from localStorage
|
|
59
|
-
|
|
46
|
+
return Object.keys(localStorage).reduce(function (accum, key) {
|
|
60
47
|
var segmentName = _this.keys.extractSegmentName(key);
|
|
61
48
|
if (segmentName) {
|
|
62
49
|
accum.push(segmentName);
|
|
63
50
|
}
|
|
64
51
|
else {
|
|
65
|
-
// @TODO @BREAKING: This is only to clean up "old" keys. Remove this whole else code block
|
|
52
|
+
// @TODO @BREAKING: This is only to clean up "old" keys. Remove this whole else code block
|
|
66
53
|
segmentName = _this.keys.extractOldSegmentKey(key);
|
|
67
54
|
if (segmentName) { // this was an old segment key, let's clean up.
|
|
68
55
|
var newSegmentKey = _this.keys.buildSegmentNameKey(segmentName);
|
|
69
56
|
try {
|
|
70
57
|
// If the new format key is not there, create it.
|
|
71
|
-
if (!localStorage.getItem(newSegmentKey)
|
|
58
|
+
if (!localStorage.getItem(newSegmentKey)) {
|
|
72
59
|
localStorage.setItem(newSegmentKey, DEFINED);
|
|
73
60
|
// we are migrating a segment, let's track it.
|
|
74
61
|
accum.push(segmentName);
|
|
@@ -82,40 +69,30 @@ var MySegmentsCacheInLocal = /** @class */ (function (_super) {
|
|
|
82
69
|
}
|
|
83
70
|
return accum;
|
|
84
71
|
}, []);
|
|
85
|
-
// Extreme fast => everything is empty
|
|
86
|
-
if (names.length === 0 && storedSegmentNames.length === names.length)
|
|
87
|
-
return isDiff;
|
|
88
|
-
// Quick path
|
|
89
|
-
if (storedSegmentNames.length !== names.length) {
|
|
90
|
-
isDiff = true;
|
|
91
|
-
storedSegmentNames.forEach(function (name) { return _this.removeFromSegment(name); });
|
|
92
|
-
names.forEach(function (name) { return _this.addToSegment(name); });
|
|
93
|
-
}
|
|
94
|
-
else {
|
|
95
|
-
// Slowest path => we need to find at least 1 difference because
|
|
96
|
-
for (index = 0; index < names.length && storedSegmentNames.indexOf(names[index]) !== -1; index++) {
|
|
97
|
-
// TODO: why empty statement?
|
|
98
|
-
}
|
|
99
|
-
if (index < names.length) {
|
|
100
|
-
isDiff = true;
|
|
101
|
-
storedSegmentNames.forEach(function (name) { return _this.removeFromSegment(name); });
|
|
102
|
-
names.forEach(function (name) { return _this.addToSegment(name); });
|
|
103
|
-
}
|
|
104
|
-
}
|
|
105
|
-
return isDiff;
|
|
106
|
-
};
|
|
107
|
-
MySegmentsCacheInLocal.prototype.getRegisteredSegments = function () {
|
|
108
|
-
var _this = this;
|
|
109
|
-
return Object.keys(localStorage).reduce(function (accum, key) {
|
|
110
|
-
var segmentName = _this.keys.extractSegmentName(key);
|
|
111
|
-
if (segmentName)
|
|
112
|
-
accum.push(segmentName);
|
|
113
|
-
return accum;
|
|
114
|
-
}, []);
|
|
115
72
|
};
|
|
116
73
|
MySegmentsCacheInLocal.prototype.getKeysCount = function () {
|
|
117
74
|
return 1;
|
|
118
75
|
};
|
|
76
|
+
MySegmentsCacheInLocal.prototype.setChangeNumber = function (name, changeNumber) {
|
|
77
|
+
try {
|
|
78
|
+
if (changeNumber)
|
|
79
|
+
localStorage.setItem(this.keys.buildTillKey(), changeNumber + '');
|
|
80
|
+
else
|
|
81
|
+
localStorage.removeItem(this.keys.buildTillKey());
|
|
82
|
+
}
|
|
83
|
+
catch (e) {
|
|
84
|
+
this.log.error(e);
|
|
85
|
+
}
|
|
86
|
+
};
|
|
87
|
+
MySegmentsCacheInLocal.prototype.getChangeNumber = function () {
|
|
88
|
+
var n = -1;
|
|
89
|
+
var value = localStorage.getItem(this.keys.buildTillKey());
|
|
90
|
+
if (value !== null) {
|
|
91
|
+
value = parseInt(value, 10);
|
|
92
|
+
return isNaNNumber(value) ? n : value;
|
|
93
|
+
}
|
|
94
|
+
return n;
|
|
95
|
+
};
|
|
119
96
|
return MySegmentsCacheInLocal;
|
|
120
97
|
}(AbstractSegmentsCacheSync));
|
|
121
98
|
export { MySegmentsCacheInLocal };
|
|
@@ -1,10 +1,9 @@
|
|
|
1
1
|
import { __extends } from "tslib";
|
|
2
|
-
import { AbstractSplitsCacheSync,
|
|
2
|
+
import { AbstractSplitsCacheSync, usesSegments } from '../AbstractSplitsCacheSync';
|
|
3
3
|
import { isFiniteNumber, toNumber, isNaNNumber } from '../../utils/lang';
|
|
4
4
|
import { LOG_PREFIX } from './constants';
|
|
5
5
|
import { _Set, setToArray } from '../../utils/lang/sets';
|
|
6
6
|
import { getStorageHash } from '../KeyBuilder';
|
|
7
|
-
import { IN_LARGE_SEGMENT, IN_SEGMENT } from '../../utils/constants';
|
|
8
7
|
/**
|
|
9
8
|
* ISplitsCacheSync implementation that stores split definitions in browser LocalStorage.
|
|
10
9
|
*/
|
|
@@ -38,14 +37,10 @@ var SplitsCacheInLocal = /** @class */ (function (_super) {
|
|
|
38
37
|
if (split) {
|
|
39
38
|
var ttKey = this.keys.buildTrafficTypeKey(split.trafficTypeName);
|
|
40
39
|
this._decrementCount(ttKey);
|
|
41
|
-
if (
|
|
40
|
+
if (usesSegments(split)) {
|
|
42
41
|
var segmentsCountKey = this.keys.buildSplitsWithSegmentCountKey();
|
|
43
42
|
this._decrementCount(segmentsCountKey);
|
|
44
43
|
}
|
|
45
|
-
if (usesMatcher(split, IN_LARGE_SEGMENT)) {
|
|
46
|
-
var segmentsCountKey = this.keys.buildSplitsWithLargeSegmentCountKey();
|
|
47
|
-
this._decrementCount(segmentsCountKey);
|
|
48
|
-
}
|
|
49
44
|
}
|
|
50
45
|
}
|
|
51
46
|
catch (e) {
|
|
@@ -58,16 +53,11 @@ var SplitsCacheInLocal = /** @class */ (function (_super) {
|
|
|
58
53
|
var ttKey = this.keys.buildTrafficTypeKey(split.trafficTypeName);
|
|
59
54
|
// @ts-expect-error
|
|
60
55
|
localStorage.setItem(ttKey, toNumber(localStorage.getItem(ttKey)) + 1);
|
|
61
|
-
if (
|
|
56
|
+
if (usesSegments(split)) {
|
|
62
57
|
var segmentsCountKey = this.keys.buildSplitsWithSegmentCountKey();
|
|
63
58
|
// @ts-expect-error
|
|
64
59
|
localStorage.setItem(segmentsCountKey, toNumber(localStorage.getItem(segmentsCountKey)) + 1);
|
|
65
60
|
}
|
|
66
|
-
if (usesMatcher(split, IN_LARGE_SEGMENT)) {
|
|
67
|
-
var segmentsCountKey = this.keys.buildSplitsWithLargeSegmentCountKey();
|
|
68
|
-
// @ts-expect-error
|
|
69
|
-
localStorage.setItem(segmentsCountKey, toNumber(localStorage.getItem(segmentsCountKey)) + 1);
|
|
70
|
-
}
|
|
71
61
|
}
|
|
72
62
|
}
|
|
73
63
|
catch (e) {
|
|
@@ -180,13 +170,11 @@ var SplitsCacheInLocal = /** @class */ (function (_super) {
|
|
|
180
170
|
var ttCount = toNumber(localStorage.getItem(this.keys.buildTrafficTypeKey(trafficType)));
|
|
181
171
|
return isFiniteNumber(ttCount) && ttCount > 0;
|
|
182
172
|
};
|
|
183
|
-
SplitsCacheInLocal.prototype.
|
|
173
|
+
SplitsCacheInLocal.prototype.usesSegments = function () {
|
|
184
174
|
// If cache hasn't been synchronized with the cloud, assume we need them.
|
|
185
175
|
if (!this.hasSync)
|
|
186
176
|
return true;
|
|
187
|
-
var storedCount = localStorage.getItem(
|
|
188
|
-
this.keys.buildSplitsWithSegmentCountKey() :
|
|
189
|
-
this.keys.buildSplitsWithLargeSegmentCountKey());
|
|
177
|
+
var storedCount = localStorage.getItem(this.keys.buildSplitsWithSegmentCountKey());
|
|
190
178
|
var splitsWithSegmentsCount = storedCount === null ? 0 : toNumber(storedCount);
|
|
191
179
|
if (isFiniteNumber(splitsWithSegmentsCount)) {
|
|
192
180
|
return splitsWithSegmentsCount > 0;
|
|
@@ -11,57 +11,26 @@ var MySegmentsCacheInMemory = /** @class */ (function (_super) {
|
|
|
11
11
|
_this.segmentCache = {};
|
|
12
12
|
return _this;
|
|
13
13
|
}
|
|
14
|
-
MySegmentsCacheInMemory.prototype.clear = function () {
|
|
15
|
-
this.segmentCache = {};
|
|
16
|
-
};
|
|
17
14
|
MySegmentsCacheInMemory.prototype.addToSegment = function (name) {
|
|
15
|
+
if (this.segmentCache[name])
|
|
16
|
+
return false;
|
|
18
17
|
this.segmentCache[name] = true;
|
|
19
18
|
return true;
|
|
20
19
|
};
|
|
21
20
|
MySegmentsCacheInMemory.prototype.removeFromSegment = function (name) {
|
|
21
|
+
if (!this.segmentCache[name])
|
|
22
|
+
return false;
|
|
22
23
|
delete this.segmentCache[name];
|
|
23
24
|
return true;
|
|
24
25
|
};
|
|
25
26
|
MySegmentsCacheInMemory.prototype.isInSegment = function (name) {
|
|
26
27
|
return this.segmentCache[name] === true;
|
|
27
28
|
};
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
* @returns boolean indicating if the cache was updated (i.e., given list was different from the cached one)
|
|
34
|
-
*/
|
|
35
|
-
MySegmentsCacheInMemory.prototype.resetSegments = function (names) {
|
|
36
|
-
var _this = this;
|
|
37
|
-
var isDiff = false;
|
|
38
|
-
var index;
|
|
39
|
-
var storedSegmentKeys = Object.keys(this.segmentCache);
|
|
40
|
-
// Extreme fast => everything is empty
|
|
41
|
-
if (names.length === 0 && storedSegmentKeys.length === names.length)
|
|
42
|
-
return isDiff;
|
|
43
|
-
// Quick path
|
|
44
|
-
if (storedSegmentKeys.length !== names.length) {
|
|
45
|
-
isDiff = true;
|
|
46
|
-
this.segmentCache = {};
|
|
47
|
-
names.forEach(function (s) {
|
|
48
|
-
_this.addToSegment(s);
|
|
49
|
-
});
|
|
50
|
-
}
|
|
51
|
-
else {
|
|
52
|
-
// Slowest path => we need to find at least 1 difference because
|
|
53
|
-
for (index = 0; index < names.length && this.isInSegment(names[index]); index++) {
|
|
54
|
-
// TODO: why empty statement?
|
|
55
|
-
}
|
|
56
|
-
if (index < names.length) {
|
|
57
|
-
isDiff = true;
|
|
58
|
-
this.segmentCache = {};
|
|
59
|
-
names.forEach(function (s) {
|
|
60
|
-
_this.addToSegment(s);
|
|
61
|
-
});
|
|
62
|
-
}
|
|
63
|
-
}
|
|
64
|
-
return isDiff;
|
|
29
|
+
MySegmentsCacheInMemory.prototype.setChangeNumber = function (name, changeNumber) {
|
|
30
|
+
this.cn = changeNumber;
|
|
31
|
+
};
|
|
32
|
+
MySegmentsCacheInMemory.prototype.getChangeNumber = function () {
|
|
33
|
+
return this.cn || -1;
|
|
65
34
|
};
|
|
66
35
|
MySegmentsCacheInMemory.prototype.getRegisteredSegments = function () {
|
|
67
36
|
return Object.keys(this.segmentCache);
|
|
@@ -1,8 +1,7 @@
|
|
|
1
1
|
import { __extends } from "tslib";
|
|
2
|
-
import { AbstractSplitsCacheSync,
|
|
2
|
+
import { AbstractSplitsCacheSync, usesSegments } from '../AbstractSplitsCacheSync';
|
|
3
3
|
import { isFiniteNumber } from '../../utils/lang';
|
|
4
4
|
import { _Set } from '../../utils/lang/sets';
|
|
5
|
-
import { IN_LARGE_SEGMENT, IN_SEGMENT } from '../../utils/constants';
|
|
6
5
|
/**
|
|
7
6
|
* Default ISplitsCacheSync implementation that stores split definitions in memory.
|
|
8
7
|
* Supported by all JS runtimes.
|
|
@@ -15,7 +14,6 @@ var SplitsCacheInMemory = /** @class */ (function (_super) {
|
|
|
15
14
|
_this.ttCache = {};
|
|
16
15
|
_this.changeNumber = -1;
|
|
17
16
|
_this.segmentsCount = 0;
|
|
18
|
-
_this.largeSegmentsCount = 0;
|
|
19
17
|
_this.flagSetsCache = {};
|
|
20
18
|
_this.flagSetsFilter = splitFiltersValidation ? splitFiltersValidation.groupedFilters.bySet : [];
|
|
21
19
|
return _this;
|
|
@@ -25,7 +23,6 @@ var SplitsCacheInMemory = /** @class */ (function (_super) {
|
|
|
25
23
|
this.ttCache = {};
|
|
26
24
|
this.changeNumber = -1;
|
|
27
25
|
this.segmentsCount = 0;
|
|
28
|
-
this.largeSegmentsCount = 0;
|
|
29
26
|
};
|
|
30
27
|
SplitsCacheInMemory.prototype.addSplit = function (name, split) {
|
|
31
28
|
var previousSplit = this.getSplit(name);
|
|
@@ -35,11 +32,9 @@ var SplitsCacheInMemory = /** @class */ (function (_super) {
|
|
|
35
32
|
if (!this.ttCache[previousTtName])
|
|
36
33
|
delete this.ttCache[previousTtName];
|
|
37
34
|
this.removeFromFlagSets(previousSplit.name, previousSplit.sets);
|
|
38
|
-
//
|
|
39
|
-
if (
|
|
35
|
+
// Subtract from segments count for the previous version of this Split
|
|
36
|
+
if (usesSegments(previousSplit))
|
|
40
37
|
this.segmentsCount--;
|
|
41
|
-
if (usesMatcher(previousSplit, IN_LARGE_SEGMENT))
|
|
42
|
-
this.largeSegmentsCount--;
|
|
43
38
|
}
|
|
44
39
|
if (split) {
|
|
45
40
|
// Store the Split.
|
|
@@ -49,10 +44,8 @@ var SplitsCacheInMemory = /** @class */ (function (_super) {
|
|
|
49
44
|
this.ttCache[ttName] = (this.ttCache[ttName] || 0) + 1;
|
|
50
45
|
this.addToFlagSets(split);
|
|
51
46
|
// Add to segments count for the new version of the Split
|
|
52
|
-
if (
|
|
47
|
+
if (usesSegments(split))
|
|
53
48
|
this.segmentsCount++;
|
|
54
|
-
if (usesMatcher(split, IN_LARGE_SEGMENT))
|
|
55
|
-
this.largeSegmentsCount++;
|
|
56
49
|
return true;
|
|
57
50
|
}
|
|
58
51
|
else {
|
|
@@ -70,10 +63,8 @@ var SplitsCacheInMemory = /** @class */ (function (_super) {
|
|
|
70
63
|
delete this.ttCache[ttName];
|
|
71
64
|
this.removeFromFlagSets(split.name, split.sets);
|
|
72
65
|
// Update the segments count.
|
|
73
|
-
if (
|
|
66
|
+
if (usesSegments(split))
|
|
74
67
|
this.segmentsCount--;
|
|
75
|
-
if (usesMatcher(split, IN_LARGE_SEGMENT))
|
|
76
|
-
this.largeSegmentsCount--;
|
|
77
68
|
return true;
|
|
78
69
|
}
|
|
79
70
|
else {
|
|
@@ -96,8 +87,8 @@ var SplitsCacheInMemory = /** @class */ (function (_super) {
|
|
|
96
87
|
SplitsCacheInMemory.prototype.trafficTypeExists = function (trafficType) {
|
|
97
88
|
return isFiniteNumber(this.ttCache[trafficType]) && this.ttCache[trafficType] > 0;
|
|
98
89
|
};
|
|
99
|
-
SplitsCacheInMemory.prototype.
|
|
100
|
-
return this.getChangeNumber() === -1 ||
|
|
90
|
+
SplitsCacheInMemory.prototype.usesSegments = function () {
|
|
91
|
+
return this.getChangeNumber() === -1 || this.segmentsCount > 0;
|
|
101
92
|
};
|
|
102
93
|
SplitsCacheInMemory.prototype.getNamesByFlagSets = function (flagSets) {
|
|
103
94
|
var _this = this;
|
|
@@ -2,20 +2,13 @@
|
|
|
2
2
|
* Factory of MySegments fetcher.
|
|
3
3
|
* MySegments fetcher is a wrapper around `mySegments` API service that parses the response and handle errors.
|
|
4
4
|
*/
|
|
5
|
-
export function mySegmentsFetcherFactory(
|
|
5
|
+
export function mySegmentsFetcherFactory(fetchMemberships) {
|
|
6
6
|
return function mySegmentsFetcher(userMatchingKey, noCache,
|
|
7
|
-
// Optional decorator for `
|
|
7
|
+
// Optional decorator for `fetchMemberships` promise, such as timeout or time tracker
|
|
8
8
|
decorator) {
|
|
9
|
-
var mySegmentsPromise =
|
|
9
|
+
var mySegmentsPromise = fetchMemberships(userMatchingKey, noCache);
|
|
10
10
|
if (decorator)
|
|
11
11
|
mySegmentsPromise = decorator(mySegmentsPromise);
|
|
12
|
-
|
|
13
|
-
return mySegmentsPromise
|
|
14
|
-
.then(function (resp) { return resp.json(); })
|
|
15
|
-
.then(function (json) {
|
|
16
|
-
return json.mySegments ?
|
|
17
|
-
json.mySegments.map(function (segment) { return segment.name; }) :
|
|
18
|
-
json.myLargeSegments;
|
|
19
|
-
});
|
|
12
|
+
return mySegmentsPromise.then(function (resp) { return resp.json(); });
|
|
20
13
|
};
|
|
21
14
|
}
|
|
@@ -20,7 +20,7 @@ function greedyFetch(fetchSegmentChanges, since, segmentName, noCache, targetTil
|
|
|
20
20
|
*/
|
|
21
21
|
export function segmentChangesFetcherFactory(fetchSegmentChanges) {
|
|
22
22
|
return function segmentChangesFetcher(since, segmentName, noCache, till,
|
|
23
|
-
// Optional decorator for `
|
|
23
|
+
// Optional decorator for `fetchSegmentChanges` promise, such as timeout or time tracker
|
|
24
24
|
decorator) {
|
|
25
25
|
var segmentsPromise = greedyFetch(fetchSegmentChanges, since, segmentName, noCache, till);
|
|
26
26
|
if (decorator)
|
|
@@ -3,8 +3,7 @@ import { mySegmentsSyncTaskFactory } from './syncTasks/mySegmentsSyncTask';
|
|
|
3
3
|
import { splitsSyncTaskFactory } from './syncTasks/splitsSyncTask';
|
|
4
4
|
import { getMatching } from '../../utils/key';
|
|
5
5
|
import { SDK_SPLITS_ARRIVED, SDK_SEGMENTS_ARRIVED } from '../../readiness/constants';
|
|
6
|
-
import { POLLING_START, POLLING_STOP } from '../../logger/constants';
|
|
7
|
-
import { IN_LARGE_SEGMENT, IN_SEGMENT } from '../../utils/constants';
|
|
6
|
+
import { POLLING_SMART_PAUSING, POLLING_START, POLLING_STOP } from '../../logger/constants';
|
|
8
7
|
/**
|
|
9
8
|
* Expose start / stop mechanism for polling data from services.
|
|
10
9
|
* For client-side API with multiple clients.
|
|
@@ -13,74 +12,59 @@ export function pollingManagerCSFactory(params) {
|
|
|
13
12
|
var splitApi = params.splitApi, storage = params.storage, readiness = params.readiness, settings = params.settings;
|
|
14
13
|
var log = settings.log;
|
|
15
14
|
var splitsSyncTask = splitsSyncTaskFactory(splitApi.fetchSplitChanges, storage, readiness, settings, true);
|
|
16
|
-
// Map of matching keys to their corresponding MySegmentsSyncTask
|
|
15
|
+
// Map of matching keys to their corresponding MySegmentsSyncTask.
|
|
17
16
|
var mySegmentsSyncTasks = {};
|
|
18
17
|
var matchingKey = getMatching(settings.core.key);
|
|
19
|
-
var
|
|
18
|
+
var mySegmentsSyncTask = add(matchingKey, readiness, storage);
|
|
20
19
|
function startMySegmentsSyncTasks() {
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
forOwn(mySegmentsSyncTasks, function (_a) {
|
|
24
|
-
var msSyncTask = _a.msSyncTask, mlsSyncTask = _a.mlsSyncTask;
|
|
25
|
-
if (splitsHaveSegments)
|
|
26
|
-
msSyncTask.start();
|
|
27
|
-
else
|
|
28
|
-
msSyncTask.stop(); // smart pausing
|
|
29
|
-
if (mlsSyncTask) {
|
|
30
|
-
if (splitsHaveLargeSegments)
|
|
31
|
-
mlsSyncTask.start();
|
|
32
|
-
else
|
|
33
|
-
mlsSyncTask.stop(); // smart pausing
|
|
34
|
-
}
|
|
20
|
+
forOwn(mySegmentsSyncTasks, function (mySegmentsSyncTask) {
|
|
21
|
+
mySegmentsSyncTask.start();
|
|
35
22
|
});
|
|
36
23
|
}
|
|
37
24
|
function stopMySegmentsSyncTasks() {
|
|
38
|
-
forOwn(mySegmentsSyncTasks, function (
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
mlsSyncTask && mlsSyncTask.stop();
|
|
25
|
+
forOwn(mySegmentsSyncTasks, function (mySegmentsSyncTask) {
|
|
26
|
+
if (mySegmentsSyncTask.isRunning())
|
|
27
|
+
mySegmentsSyncTask.stop();
|
|
42
28
|
});
|
|
43
29
|
}
|
|
30
|
+
// smart pausing
|
|
44
31
|
readiness.splits.on(SDK_SPLITS_ARRIVED, function () {
|
|
45
|
-
if (splitsSyncTask.isRunning())
|
|
46
|
-
|
|
32
|
+
if (!splitsSyncTask.isRunning())
|
|
33
|
+
return; // noop if not doing polling
|
|
34
|
+
var splitsHaveSegments = storage.splits.usesSegments();
|
|
35
|
+
if (splitsHaveSegments !== mySegmentsSyncTask.isRunning()) {
|
|
36
|
+
log.info(POLLING_SMART_PAUSING, [splitsHaveSegments ? 'ON' : 'OFF']);
|
|
37
|
+
if (splitsHaveSegments) {
|
|
38
|
+
startMySegmentsSyncTasks();
|
|
39
|
+
}
|
|
40
|
+
else {
|
|
41
|
+
stopMySegmentsSyncTasks();
|
|
42
|
+
}
|
|
43
|
+
}
|
|
47
44
|
});
|
|
48
45
|
function add(matchingKey, readiness, storage) {
|
|
49
|
-
var
|
|
50
|
-
readiness.segments.emit(SDK_SEGMENTS_ARRIVED); }, settings, matchingKey, settings.scheduler.segmentsRefreshRate, 'mySegmentsUpdater');
|
|
51
|
-
var mlsSyncTask;
|
|
52
|
-
if (settings.sync.largeSegmentsEnabled) {
|
|
53
|
-
mlsSyncTask = mySegmentsSyncTaskFactory(splitApi.fetchMyLargeSegments, storage.largeSegments, function () { if (readiness.largeSegments && storage.splits.usesMatcher(IN_LARGE_SEGMENT))
|
|
54
|
-
readiness.largeSegments.emit(SDK_SEGMENTS_ARRIVED); }, settings, matchingKey, settings.scheduler.largeSegmentsRefreshRate, 'myLargeSegmentsUpdater');
|
|
55
|
-
}
|
|
46
|
+
var mySegmentsSyncTask = mySegmentsSyncTaskFactory(splitApi.fetchMemberships, storage, readiness, settings, matchingKey);
|
|
56
47
|
// smart ready
|
|
57
48
|
function smartReady() {
|
|
58
|
-
if (!readiness.isReady())
|
|
59
|
-
|
|
60
|
-
readiness.largeSegments.emit(SDK_SEGMENTS_ARRIVED);
|
|
61
|
-
if (!storage.splits.usesMatcher(IN_SEGMENT))
|
|
62
|
-
readiness.segments.emit(SDK_SEGMENTS_ARRIVED);
|
|
63
|
-
}
|
|
49
|
+
if (!readiness.isReady() && !storage.splits.usesSegments())
|
|
50
|
+
readiness.segments.emit(SDK_SEGMENTS_ARRIVED);
|
|
64
51
|
}
|
|
65
|
-
if (storage.splits.
|
|
66
|
-
readiness.splits.once(SDK_SPLITS_ARRIVED, smartReady);
|
|
67
|
-
else
|
|
52
|
+
if (!storage.splits.usesSegments())
|
|
68
53
|
setTimeout(smartReady, 0);
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
};
|
|
54
|
+
else
|
|
55
|
+
readiness.splits.once(SDK_SPLITS_ARRIVED, smartReady);
|
|
56
|
+
mySegmentsSyncTasks[matchingKey] = mySegmentsSyncTask;
|
|
57
|
+
return mySegmentsSyncTask;
|
|
74
58
|
}
|
|
75
59
|
return {
|
|
76
60
|
splitsSyncTask: splitsSyncTask,
|
|
77
|
-
segmentsSyncTask:
|
|
78
|
-
largeSegmentsSyncTask: mlsSyncTask,
|
|
61
|
+
segmentsSyncTask: mySegmentsSyncTask,
|
|
79
62
|
// Start periodic fetching (polling)
|
|
80
63
|
start: function () {
|
|
81
64
|
log.info(POLLING_START);
|
|
82
65
|
splitsSyncTask.start();
|
|
83
|
-
|
|
66
|
+
if (storage.splits.usesSegments())
|
|
67
|
+
startMySegmentsSyncTasks();
|
|
84
68
|
},
|
|
85
69
|
// Stop periodic fetching (polling)
|
|
86
70
|
stop: function () {
|
|
@@ -94,10 +78,8 @@ export function pollingManagerCSFactory(params) {
|
|
|
94
78
|
// fetch splits and segments
|
|
95
79
|
syncAll: function () {
|
|
96
80
|
var promises = [splitsSyncTask.execute()];
|
|
97
|
-
forOwn(mySegmentsSyncTasks, function (
|
|
98
|
-
|
|
99
|
-
promises.push(msSyncTask.execute());
|
|
100
|
-
mlsSyncTask && promises.push(mlsSyncTask.execute());
|
|
81
|
+
forOwn(mySegmentsSyncTasks, function (mySegmentsSyncTask) {
|
|
82
|
+
promises.push(mySegmentsSyncTask.execute());
|
|
101
83
|
});
|
|
102
84
|
return Promise.all(promises);
|
|
103
85
|
},
|
|
@@ -4,6 +4,6 @@ import { mySegmentsUpdaterFactory } from '../updaters/mySegmentsUpdater';
|
|
|
4
4
|
/**
|
|
5
5
|
* Creates a sync task that periodically executes a `mySegmentsUpdater` task
|
|
6
6
|
*/
|
|
7
|
-
export function mySegmentsSyncTaskFactory(
|
|
8
|
-
return syncTaskFactory(settings.log, mySegmentsUpdaterFactory(settings.log, mySegmentsFetcherFactory(
|
|
7
|
+
export function mySegmentsSyncTaskFactory(fetchMemberships, storage, readiness, settings, matchingKey) {
|
|
8
|
+
return syncTaskFactory(settings.log, mySegmentsUpdaterFactory(settings.log, mySegmentsFetcherFactory(fetchMemberships), storage, readiness.segments, settings.startup.requestTimeoutBeforeReady, settings.startup.retriesOnFailureBeforeReady, matchingKey), settings.scheduler.segmentsRefreshRate, 'mySegmentsUpdater');
|
|
9
9
|
}
|
|
@@ -1,12 +1,15 @@
|
|
|
1
1
|
import { timeout } from '../../../utils/promise/timeout';
|
|
2
|
+
import { SDK_SEGMENTS_ARRIVED } from '../../../readiness/constants';
|
|
2
3
|
import { SYNC_MYSEGMENTS_FETCH_RETRY } from '../../../logger/constants';
|
|
4
|
+
import { MEMBERSHIP_LS_UPDATE } from '../../streaming/constants';
|
|
3
5
|
/**
|
|
4
6
|
* factory of MySegments updater, a task that:
|
|
5
7
|
* - fetches mySegments using `mySegmentsFetcher`
|
|
6
8
|
* - updates `mySegmentsCache`
|
|
7
9
|
* - uses `segmentsEventEmitter` to emit events related to segments data updates
|
|
8
10
|
*/
|
|
9
|
-
export function mySegmentsUpdaterFactory(log, mySegmentsFetcher,
|
|
11
|
+
export function mySegmentsUpdaterFactory(log, mySegmentsFetcher, storage, segmentsEventEmitter, requestTimeoutBeforeReady, retriesOnFailureBeforeReady, matchingKey) {
|
|
12
|
+
var splits = storage.splits, segments = storage.segments, largeSegments = storage.largeSegments;
|
|
10
13
|
var readyOnAlreadyExistentState = true;
|
|
11
14
|
var startingUp = true;
|
|
12
15
|
/** timeout and telemetry decorator for `splitChangesFetcher` promise */
|
|
@@ -18,28 +21,19 @@ export function mySegmentsUpdaterFactory(log, mySegmentsFetcher, mySegmentsCache
|
|
|
18
21
|
// @TODO if allowing pluggable storages, handle async execution
|
|
19
22
|
function updateSegments(segmentsData) {
|
|
20
23
|
var shouldNotifyUpdate;
|
|
21
|
-
if (
|
|
22
|
-
|
|
23
|
-
|
|
24
|
+
if (segmentsData.type !== undefined) {
|
|
25
|
+
shouldNotifyUpdate = segmentsData.type === MEMBERSHIP_LS_UPDATE ?
|
|
26
|
+
largeSegments.resetSegments(segmentsData) :
|
|
27
|
+
segments.resetSegments(segmentsData);
|
|
24
28
|
}
|
|
25
29
|
else {
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
if (mySegmentsCache.isInSegment(name_1) !== add) {
|
|
29
|
-
shouldNotifyUpdate = true;
|
|
30
|
-
if (add)
|
|
31
|
-
mySegmentsCache.addToSegment(name_1);
|
|
32
|
-
else
|
|
33
|
-
mySegmentsCache.removeFromSegment(name_1);
|
|
34
|
-
}
|
|
35
|
-
else {
|
|
36
|
-
shouldNotifyUpdate = false;
|
|
37
|
-
}
|
|
30
|
+
shouldNotifyUpdate = segments.resetSegments(segmentsData.ms || {});
|
|
31
|
+
shouldNotifyUpdate = largeSegments.resetSegments(segmentsData.ls || {}) || shouldNotifyUpdate;
|
|
38
32
|
}
|
|
39
33
|
// Notify update if required
|
|
40
|
-
if (shouldNotifyUpdate || readyOnAlreadyExistentState) {
|
|
34
|
+
if (splits.usesSegments() && (shouldNotifyUpdate || readyOnAlreadyExistentState)) {
|
|
41
35
|
readyOnAlreadyExistentState = false;
|
|
42
|
-
|
|
36
|
+
segmentsEventEmitter.emit(SDK_SEGMENTS_ARRIVED);
|
|
43
37
|
}
|
|
44
38
|
}
|
|
45
39
|
function _mySegmentsUpdater(retry, segmentsData, noCache) {
|
|
@@ -10,7 +10,7 @@ import { hash } from '../../../utils/murmur3/murmur3';
|
|
|
10
10
|
export function authenticateFactory(fetchAuth) {
|
|
11
11
|
/**
|
|
12
12
|
* Run authentication requests to Auth Server, and returns a promise that resolves with the decoded JTW token.
|
|
13
|
-
* @param {string[] | undefined} userKeys set of user Keys to track
|
|
13
|
+
* @param {string[] | undefined} userKeys set of user Keys to track membership updates. It is undefined for server-side API.
|
|
14
14
|
*/
|
|
15
15
|
return function authenticate(userKeys) {
|
|
16
16
|
return fetchAuth(userKeys)
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { errorParser, messageParser } from './NotificationParser';
|
|
2
2
|
import { notificationKeeperFactory } from './NotificationKeeper';
|
|
3
|
-
import { PUSH_RETRYABLE_ERROR, PUSH_NONRETRYABLE_ERROR, OCCUPANCY, CONTROL,
|
|
3
|
+
import { PUSH_RETRYABLE_ERROR, PUSH_NONRETRYABLE_ERROR, OCCUPANCY, CONTROL, SEGMENT_UPDATE, SPLIT_KILL, SPLIT_UPDATE, MEMBERSHIP_MS_UPDATE, MEMBERSHIP_LS_UPDATE } from '../constants';
|
|
4
4
|
import { STREAMING_PARSING_ERROR_FAILS, ERROR_STREAMING_SSE, STREAMING_PARSING_MESSAGE_FAILS, STREAMING_NEW_MESSAGE } from '../../../logger/constants';
|
|
5
5
|
import { ABLY_ERROR, NON_REQUESTED, SSE_CONNECTION_ERROR } from '../../../utils/constants';
|
|
6
6
|
/**
|
|
@@ -65,21 +65,18 @@ export function SSEHandlerFactory(log, pushEmitter, telemetryTracker) {
|
|
|
65
65
|
}
|
|
66
66
|
var parsedData = messageWithParsedData.parsedData, data = messageWithParsedData.data, channel = messageWithParsedData.channel, timestamp = messageWithParsedData.timestamp;
|
|
67
67
|
log.debug(STREAMING_NEW_MESSAGE, [data]);
|
|
68
|
-
// we only handle update events if streaming is up
|
|
68
|
+
// we only handle update events if streaming is up
|
|
69
69
|
if (!notificationKeeper.isStreamingUp() && [OCCUPANCY, CONTROL].indexOf(parsedData.type) === -1)
|
|
70
70
|
return;
|
|
71
71
|
switch (parsedData.type) {
|
|
72
72
|
/* update events */
|
|
73
73
|
case SPLIT_UPDATE:
|
|
74
74
|
case SEGMENT_UPDATE:
|
|
75
|
-
case
|
|
76
|
-
case
|
|
75
|
+
case MEMBERSHIP_MS_UPDATE:
|
|
76
|
+
case MEMBERSHIP_LS_UPDATE:
|
|
77
77
|
case SPLIT_KILL:
|
|
78
78
|
pushEmitter.emit(parsedData.type, parsedData);
|
|
79
79
|
break;
|
|
80
|
-
case MY_SEGMENTS_UPDATE:
|
|
81
|
-
pushEmitter.emit(parsedData.type, parsedData, channel);
|
|
82
|
-
break;
|
|
83
80
|
/* occupancy & control events, handled by NotificationManagerKeeper */
|
|
84
81
|
case OCCUPANCY:
|
|
85
82
|
notificationKeeper.handleOccupancyEvent(parsedData.metrics.publishers, channel, timestamp);
|