@splitsoftware/splitio-commons 1.17.0 → 1.17.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 +8 -0
- package/cjs/evaluator/matchers/index.js +3 -1
- package/cjs/evaluator/matchers/large_segment.js +16 -0
- package/cjs/evaluator/matchers/matcherTypes.js +1 -0
- package/cjs/evaluator/matchersTransform/index.js +4 -1
- package/cjs/evaluator/matchersTransform/segment.js +3 -1
- package/cjs/logger/constants.js +2 -2
- package/cjs/logger/messages/info.js +1 -1
- package/cjs/logger/messages/warn.js +1 -1
- package/cjs/readiness/readinessManager.js +5 -6
- package/cjs/readiness/sdkReadinessManager.js +5 -6
- package/cjs/sdkClient/identity.js +7 -0
- package/cjs/sdkClient/sdkClient.js +5 -5
- package/cjs/sdkClient/sdkClientMethod.js +3 -1
- package/cjs/sdkClient/sdkClientMethodCS.js +9 -14
- package/cjs/sdkClient/sdkClientMethodCSWithTT.js +9 -14
- package/cjs/sdkFactory/index.js +6 -2
- package/cjs/services/splitApi.js +5 -5
- package/cjs/storages/AbstractSegmentsCacheSync.js +41 -12
- package/cjs/storages/AbstractSplitsCacheSync.js +2 -1
- package/cjs/storages/KeyBuilderCS.js +23 -5
- package/cjs/storages/dataLoader.js +1 -1
- package/cjs/storages/inLocalStorage/MySegmentsCacheInLocal.js +29 -52
- package/cjs/storages/inLocalStorage/index.js +6 -2
- package/cjs/storages/inMemory/InMemoryStorageCS.js +5 -0
- package/cjs/storages/inMemory/MySegmentsCacheInMemory.js +9 -40
- package/cjs/storages/inMemory/SplitsCacheInMemory.js +8 -8
- package/cjs/storages/inMemory/TelemetryCacheInMemory.js +7 -10
- package/cjs/storages/pluggable/inMemoryWrapper.js +1 -1
- package/cjs/sync/polling/fetchers/mySegmentsFetcher.js +5 -8
- package/cjs/sync/polling/fetchers/segmentChangesFetcher.js +1 -1
- package/cjs/sync/polling/pollingManagerCS.js +1 -1
- package/cjs/sync/polling/syncTasks/mySegmentsSyncTask.js +2 -2
- package/cjs/sync/polling/updaters/mySegmentsUpdater.js +15 -21
- package/cjs/sync/streaming/AuthClient/index.js +1 -1
- package/cjs/sync/streaming/SSEHandler/index.js +3 -5
- package/cjs/sync/streaming/UpdateWorkers/MySegmentsUpdateWorker.js +107 -48
- package/cjs/sync/streaming/constants.js +3 -3
- package/cjs/sync/streaming/parseUtils.js +14 -9
- package/cjs/sync/streaming/pushManager.js +69 -67
- package/cjs/utils/constants/index.js +5 -4
- package/cjs/utils/settingsValidation/index.js +2 -1
- package/esm/evaluator/matchers/index.js +3 -1
- package/esm/evaluator/matchers/large_segment.js +12 -0
- package/esm/evaluator/matchers/matcherTypes.js +1 -0
- package/esm/evaluator/matchersTransform/index.js +4 -1
- package/esm/evaluator/matchersTransform/segment.js +3 -1
- package/esm/logger/constants.js +1 -1
- package/esm/logger/messages/info.js +1 -1
- package/esm/logger/messages/warn.js +1 -1
- package/esm/readiness/readinessManager.js +5 -6
- package/esm/readiness/sdkReadinessManager.js +5 -6
- package/esm/sdkClient/identity.js +3 -0
- package/esm/sdkClient/sdkClient.js +5 -5
- package/esm/sdkClient/sdkClientMethod.js +3 -1
- package/esm/sdkClient/sdkClientMethodCS.js +7 -12
- package/esm/sdkClient/sdkClientMethodCSWithTT.js +7 -12
- package/esm/sdkFactory/index.js +6 -2
- package/esm/services/splitApi.js +6 -6
- package/esm/storages/AbstractSegmentsCacheSync.js +41 -12
- package/esm/storages/AbstractSplitsCacheSync.js +3 -2
- package/esm/storages/KeyBuilderCS.js +21 -4
- package/esm/storages/dataLoader.js +1 -1
- package/esm/storages/inLocalStorage/MySegmentsCacheInLocal.js +29 -52
- package/esm/storages/inLocalStorage/index.js +7 -3
- package/esm/storages/inMemory/InMemoryStorageCS.js +5 -0
- package/esm/storages/inMemory/MySegmentsCacheInMemory.js +9 -40
- package/esm/storages/inMemory/SplitsCacheInMemory.js +8 -8
- package/esm/storages/inMemory/TelemetryCacheInMemory.js +7 -10
- package/esm/storages/pluggable/inMemoryWrapper.js +1 -1
- package/esm/sync/polling/fetchers/mySegmentsFetcher.js +5 -8
- package/esm/sync/polling/fetchers/segmentChangesFetcher.js +1 -1
- package/esm/sync/polling/pollingManagerCS.js +1 -1
- package/esm/sync/polling/syncTasks/mySegmentsSyncTask.js +2 -2
- package/esm/sync/polling/updaters/mySegmentsUpdater.js +15 -21
- package/esm/sync/streaming/AuthClient/index.js +1 -1
- package/esm/sync/streaming/SSEHandler/index.js +4 -6
- package/esm/sync/streaming/UpdateWorkers/MySegmentsUpdateWorker.js +108 -49
- package/esm/sync/streaming/constants.js +2 -2
- package/esm/sync/streaming/parseUtils.js +12 -8
- package/esm/sync/streaming/pushManager.js +72 -70
- package/esm/utils/constants/index.js +3 -2
- package/esm/utils/settingsValidation/index.js +2 -1
- package/package.json +1 -1
- package/src/dtos/types.ts +21 -7
- package/src/evaluator/matchers/index.ts +2 -0
- package/src/evaluator/matchers/large_segment.ts +18 -0
- package/src/evaluator/matchers/matcherTypes.ts +1 -0
- package/src/evaluator/matchersTransform/index.ts +4 -1
- package/src/evaluator/matchersTransform/segment.ts +5 -3
- package/src/logger/constants.ts +1 -1
- package/src/logger/messages/info.ts +1 -1
- package/src/logger/messages/warn.ts +1 -1
- package/src/readiness/readinessManager.ts +7 -5
- package/src/readiness/sdkReadinessManager.ts +7 -7
- package/src/readiness/types.ts +2 -2
- package/src/sdkClient/identity.ts +5 -0
- package/src/sdkClient/sdkClient.ts +5 -5
- package/src/sdkClient/sdkClientMethod.ts +4 -1
- package/src/sdkClient/sdkClientMethodCS.ts +7 -13
- package/src/sdkClient/sdkClientMethodCSWithTT.ts +7 -13
- package/src/sdkFactory/index.ts +8 -4
- package/src/sdkFactory/types.ts +2 -1
- package/src/services/splitApi.ts +7 -7
- package/src/services/splitHttpClient.ts +1 -1
- package/src/services/types.ts +2 -2
- package/src/storages/AbstractSegmentsCacheSync.ts +53 -12
- package/src/storages/AbstractSplitsCacheSync.ts +4 -3
- package/src/storages/KeyBuilderCS.ts +34 -5
- package/src/storages/dataLoader.ts +1 -1
- package/src/storages/inLocalStorage/MySegmentsCacheInLocal.ts +29 -59
- package/src/storages/inLocalStorage/index.ts +8 -4
- package/src/storages/inMemory/InMemoryStorageCS.ts +5 -0
- package/src/storages/inMemory/MySegmentsCacheInMemory.ts +10 -44
- package/src/storages/inMemory/SplitsCacheInMemory.ts +7 -8
- package/src/storages/inMemory/TelemetryCacheInMemory.ts +7 -11
- package/src/storages/pluggable/inMemoryWrapper.ts +1 -1
- package/src/storages/types.ts +11 -7
- package/src/sync/polling/fetchers/mySegmentsFetcher.ts +8 -10
- package/src/sync/polling/fetchers/segmentChangesFetcher.ts +1 -1
- package/src/sync/polling/fetchers/types.ts +3 -2
- package/src/sync/polling/pollingManagerCS.ts +4 -4
- package/src/sync/polling/syncTasks/mySegmentsSyncTask.ts +4 -5
- package/src/sync/polling/types.ts +7 -6
- package/src/sync/polling/updaters/mySegmentsUpdater.ts +19 -22
- 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 -8
- package/src/sync/streaming/SSEHandler/types.ts +15 -15
- package/src/sync/streaming/UpdateWorkers/MySegmentsUpdateWorker.ts +116 -49
- 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 -2
- package/src/sync/streaming/parseUtils.ts +19 -11
- package/src/sync/streaming/pushManager.ts +73 -72
- package/src/sync/streaming/types.ts +10 -10
- package/src/sync/submitters/types.ts +8 -5
- package/src/types.ts +7 -1
- package/src/utils/constants/index.ts +3 -2
- package/src/utils/settingsValidation/index.ts +3 -2
- package/src/utils/settingsValidation/types.ts +1 -1
- package/types/dtos/types.d.ts +18 -7
- package/types/evaluator/matchersTransform/segment.d.ts +2 -2
- package/types/logger/constants.d.ts +1 -1
- package/types/readiness/readinessManager.d.ts +2 -2
- package/types/readiness/sdkReadinessManager.d.ts +2 -3
- package/types/readiness/types.d.ts +2 -2
- package/types/sdkClient/identity.d.ts +0 -4
- package/types/sdkClient/sdkClientMethod.d.ts +1 -1
- package/types/sdkFactory/types.d.ts +2 -1
- package/types/services/splitApi.d.ts +1 -1
- package/types/services/splitHttpClient.d.ts +1 -1
- package/types/services/types.d.ts +2 -2
- package/types/storages/AbstractMySegmentsCacheSync.d.ts +39 -0
- package/types/storages/AbstractSegmentsCacheSync.d.ts +9 -11
- package/types/storages/AbstractSplitsCacheSync.d.ts +1 -1
- package/types/storages/KeyBuilderCS.d.ts +9 -2
- package/types/storages/inLocalStorage/MySegmentsCacheInLocal.d.ts +4 -14
- package/types/storages/inMemory/MySegmentsCacheInMemory.d.ts +3 -9
- package/types/storages/inMemory/SplitsCacheInMemory.d.ts +1 -1
- package/types/storages/inMemory/TelemetryCacheInMemory.d.ts +4 -6
- package/types/storages/pluggable/inMemoryWrapper.d.ts +1 -1
- package/types/storages/types.d.ts +7 -5
- 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 +2 -2
- package/types/sync/polling/types.d.ts +7 -4
- package/types/sync/polling/updaters/mySegmentsUpdater.d.ts +4 -3
- package/types/sync/streaming/SSEHandler/types.d.ts +16 -14
- package/types/sync/streaming/UpdateWorkers/MySegmentsUpdateWorker.d.ts +4 -2
- 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 -2
- package/types/sync/streaming/parseUtils.d.ts +4 -5
- package/types/sync/streaming/types.d.ts +8 -8
- package/types/sync/submitters/types.d.ts +7 -4
- package/types/types.d.ts +7 -1
- package/types/utils/constants/index.d.ts +3 -2
- package/types/utils/settingsValidation/types.d.ts +1 -1
|
@@ -2,6 +2,7 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.MySegmentsCacheInLocal = void 0;
|
|
4
4
|
var tslib_1 = require("tslib");
|
|
5
|
+
var lang_1 = require("../../utils/lang");
|
|
5
6
|
var AbstractSegmentsCacheSync_1 = require("../AbstractSegmentsCacheSync");
|
|
6
7
|
var constants_1 = require("./constants");
|
|
7
8
|
var MySegmentsCacheInLocal = /** @class */ (function (_super) {
|
|
@@ -13,19 +14,11 @@ var MySegmentsCacheInLocal = /** @class */ (function (_super) {
|
|
|
13
14
|
return _this;
|
|
14
15
|
// There is not need to flush segments cache like splits cache, since resetSegments receives the up-to-date list of active segments
|
|
15
16
|
}
|
|
16
|
-
/**
|
|
17
|
-
* Removes list of segments from localStorage
|
|
18
|
-
* @NOTE this method is not being used at the moment.
|
|
19
|
-
*/
|
|
20
|
-
MySegmentsCacheInLocal.prototype.clear = function () {
|
|
21
|
-
this.log.info(constants_1.LOG_PREFIX + 'Flushing MySegments data from localStorage');
|
|
22
|
-
// We cannot simply call `localStorage.clear()` since that implies removing user items from the storage
|
|
23
|
-
// We could optimize next sentence, since it implies iterating over all localStorage items
|
|
24
|
-
this.resetSegments([]);
|
|
25
|
-
};
|
|
26
17
|
MySegmentsCacheInLocal.prototype.addToSegment = function (name) {
|
|
27
18
|
var segmentKey = this.keys.buildSegmentNameKey(name);
|
|
28
19
|
try {
|
|
20
|
+
if (localStorage.getItem(segmentKey) === constants_1.DEFINED)
|
|
21
|
+
return false;
|
|
29
22
|
localStorage.setItem(segmentKey, constants_1.DEFINED);
|
|
30
23
|
return true;
|
|
31
24
|
}
|
|
@@ -37,6 +30,8 @@ var MySegmentsCacheInLocal = /** @class */ (function (_super) {
|
|
|
37
30
|
MySegmentsCacheInLocal.prototype.removeFromSegment = function (name) {
|
|
38
31
|
var segmentKey = this.keys.buildSegmentNameKey(name);
|
|
39
32
|
try {
|
|
33
|
+
if (localStorage.getItem(segmentKey) !== constants_1.DEFINED)
|
|
34
|
+
return false;
|
|
40
35
|
localStorage.removeItem(segmentKey);
|
|
41
36
|
return true;
|
|
42
37
|
}
|
|
@@ -48,30 +43,22 @@ var MySegmentsCacheInLocal = /** @class */ (function (_super) {
|
|
|
48
43
|
MySegmentsCacheInLocal.prototype.isInSegment = function (name) {
|
|
49
44
|
return localStorage.getItem(this.keys.buildSegmentNameKey(name)) === constants_1.DEFINED;
|
|
50
45
|
};
|
|
51
|
-
|
|
52
|
-
* Reset (update) the cached list of segments with the given list, removing and adding segments if necessary.
|
|
53
|
-
*
|
|
54
|
-
* @param {string[]} segmentNames list of segment names
|
|
55
|
-
* @returns boolean indicating if the cache was updated (i.e., given list was different from the cached one)
|
|
56
|
-
*/
|
|
57
|
-
MySegmentsCacheInLocal.prototype.resetSegments = function (names) {
|
|
46
|
+
MySegmentsCacheInLocal.prototype.getRegisteredSegments = function () {
|
|
58
47
|
var _this = this;
|
|
59
|
-
var isDiff = false;
|
|
60
|
-
var index;
|
|
61
48
|
// Scan current values from localStorage
|
|
62
|
-
|
|
49
|
+
return Object.keys(localStorage).reduce(function (accum, key) {
|
|
63
50
|
var segmentName = _this.keys.extractSegmentName(key);
|
|
64
51
|
if (segmentName) {
|
|
65
52
|
accum.push(segmentName);
|
|
66
53
|
}
|
|
67
54
|
else {
|
|
68
|
-
// @TODO @BREAKING: This is only to clean up "old" keys. Remove this whole else code block
|
|
55
|
+
// @TODO @BREAKING: This is only to clean up "old" keys. Remove this whole else code block
|
|
69
56
|
segmentName = _this.keys.extractOldSegmentKey(key);
|
|
70
57
|
if (segmentName) { // this was an old segment key, let's clean up.
|
|
71
58
|
var newSegmentKey = _this.keys.buildSegmentNameKey(segmentName);
|
|
72
59
|
try {
|
|
73
60
|
// If the new format key is not there, create it.
|
|
74
|
-
if (!localStorage.getItem(newSegmentKey)
|
|
61
|
+
if (!localStorage.getItem(newSegmentKey)) {
|
|
75
62
|
localStorage.setItem(newSegmentKey, constants_1.DEFINED);
|
|
76
63
|
// we are migrating a segment, let's track it.
|
|
77
64
|
accum.push(segmentName);
|
|
@@ -85,40 +72,30 @@ var MySegmentsCacheInLocal = /** @class */ (function (_super) {
|
|
|
85
72
|
}
|
|
86
73
|
return accum;
|
|
87
74
|
}, []);
|
|
88
|
-
// Extreme fast => everything is empty
|
|
89
|
-
if (names.length === 0 && storedSegmentNames.length === names.length)
|
|
90
|
-
return isDiff;
|
|
91
|
-
// Quick path
|
|
92
|
-
if (storedSegmentNames.length !== names.length) {
|
|
93
|
-
isDiff = true;
|
|
94
|
-
storedSegmentNames.forEach(function (name) { return _this.removeFromSegment(name); });
|
|
95
|
-
names.forEach(function (name) { return _this.addToSegment(name); });
|
|
96
|
-
}
|
|
97
|
-
else {
|
|
98
|
-
// Slowest path => we need to find at least 1 difference because
|
|
99
|
-
for (index = 0; index < names.length && storedSegmentNames.indexOf(names[index]) !== -1; index++) {
|
|
100
|
-
// TODO: why empty statement?
|
|
101
|
-
}
|
|
102
|
-
if (index < names.length) {
|
|
103
|
-
isDiff = true;
|
|
104
|
-
storedSegmentNames.forEach(function (name) { return _this.removeFromSegment(name); });
|
|
105
|
-
names.forEach(function (name) { return _this.addToSegment(name); });
|
|
106
|
-
}
|
|
107
|
-
}
|
|
108
|
-
return isDiff;
|
|
109
|
-
};
|
|
110
|
-
MySegmentsCacheInLocal.prototype.getRegisteredSegments = function () {
|
|
111
|
-
var _this = this;
|
|
112
|
-
return Object.keys(localStorage).reduce(function (accum, key) {
|
|
113
|
-
var segmentName = _this.keys.extractSegmentName(key);
|
|
114
|
-
if (segmentName)
|
|
115
|
-
accum.push(segmentName);
|
|
116
|
-
return accum;
|
|
117
|
-
}, []);
|
|
118
75
|
};
|
|
119
76
|
MySegmentsCacheInLocal.prototype.getKeysCount = function () {
|
|
120
77
|
return 1;
|
|
121
78
|
};
|
|
79
|
+
MySegmentsCacheInLocal.prototype.setChangeNumber = function (name, changeNumber) {
|
|
80
|
+
try {
|
|
81
|
+
if (changeNumber)
|
|
82
|
+
localStorage.setItem(this.keys.buildTillKey(), changeNumber + '');
|
|
83
|
+
else
|
|
84
|
+
localStorage.removeItem(this.keys.buildTillKey());
|
|
85
|
+
}
|
|
86
|
+
catch (e) {
|
|
87
|
+
this.log.error(e);
|
|
88
|
+
}
|
|
89
|
+
};
|
|
90
|
+
MySegmentsCacheInLocal.prototype.getChangeNumber = function () {
|
|
91
|
+
var n = -1;
|
|
92
|
+
var value = localStorage.getItem(this.keys.buildTillKey());
|
|
93
|
+
if (value !== null) {
|
|
94
|
+
value = parseInt(value, 10);
|
|
95
|
+
return (0, lang_1.isNaNNumber)(value) ? n : value;
|
|
96
|
+
}
|
|
97
|
+
return n;
|
|
98
|
+
};
|
|
122
99
|
return MySegmentsCacheInLocal;
|
|
123
100
|
}(AbstractSegmentsCacheSync_1.AbstractSegmentsCacheSync));
|
|
124
101
|
exports.MySegmentsCacheInLocal = MySegmentsCacheInLocal;
|
|
@@ -36,9 +36,11 @@ function InLocalStorage(options) {
|
|
|
36
36
|
var expirationTimestamp = Date.now() - browser_1.DEFAULT_CACHE_EXPIRATION_IN_MILLIS;
|
|
37
37
|
var splits = new SplitsCacheInLocal_1.SplitsCacheInLocal(settings, keys, expirationTimestamp);
|
|
38
38
|
var segments = new MySegmentsCacheInLocal_1.MySegmentsCacheInLocal(log, keys);
|
|
39
|
+
var largeSegments = new MySegmentsCacheInLocal_1.MySegmentsCacheInLocal(log, (0, KeyBuilderCS_1.myLargeSegmentsKeyBuilder)(prefix, matchingKey));
|
|
39
40
|
return {
|
|
40
41
|
splits: splits,
|
|
41
42
|
segments: segments,
|
|
43
|
+
largeSegments: largeSegments,
|
|
42
44
|
impressions: new ImpressionsCacheInMemory_1.ImpressionsCacheInMemory(impressionsQueueSize),
|
|
43
45
|
impressionCounts: impressionsMode !== constants_2.DEBUG ? new ImpressionCountsCacheInMemory_1.ImpressionCountsCacheInMemory() : undefined,
|
|
44
46
|
events: new EventsCacheInMemory_1.EventsCacheInMemory(eventsQueueSize),
|
|
@@ -48,6 +50,7 @@ function InLocalStorage(options) {
|
|
|
48
50
|
var _a;
|
|
49
51
|
this.splits = new SplitsCacheInMemory_1.SplitsCacheInMemory(__splitFiltersValidation);
|
|
50
52
|
this.segments = new MySegmentsCacheInMemory_1.MySegmentsCacheInMemory();
|
|
53
|
+
this.largeSegments = new MySegmentsCacheInMemory_1.MySegmentsCacheInMemory();
|
|
51
54
|
this.impressions.clear();
|
|
52
55
|
this.impressionCounts && this.impressionCounts.clear();
|
|
53
56
|
this.events.clear();
|
|
@@ -55,10 +58,10 @@ function InLocalStorage(options) {
|
|
|
55
58
|
},
|
|
56
59
|
// When using shared instanciation with MEMORY we reuse everything but segments (they are customer per key).
|
|
57
60
|
shared: function (matchingKey) {
|
|
58
|
-
var childKeysBuilder = new KeyBuilderCS_1.KeyBuilderCS(prefix, matchingKey);
|
|
59
61
|
return {
|
|
60
62
|
splits: this.splits,
|
|
61
|
-
segments: new MySegmentsCacheInLocal_1.MySegmentsCacheInLocal(log,
|
|
63
|
+
segments: new MySegmentsCacheInLocal_1.MySegmentsCacheInLocal(log, new KeyBuilderCS_1.KeyBuilderCS(prefix, matchingKey)),
|
|
64
|
+
largeSegments: new MySegmentsCacheInLocal_1.MySegmentsCacheInLocal(log, (0, KeyBuilderCS_1.myLargeSegmentsKeyBuilder)(prefix, matchingKey)),
|
|
62
65
|
impressions: this.impressions,
|
|
63
66
|
impressionCounts: this.impressionCounts,
|
|
64
67
|
events: this.events,
|
|
@@ -66,6 +69,7 @@ function InLocalStorage(options) {
|
|
|
66
69
|
destroy: function () {
|
|
67
70
|
this.splits = new SplitsCacheInMemory_1.SplitsCacheInMemory(__splitFiltersValidation);
|
|
68
71
|
this.segments = new MySegmentsCacheInMemory_1.MySegmentsCacheInMemory();
|
|
72
|
+
this.largeSegments = new MySegmentsCacheInMemory_1.MySegmentsCacheInMemory();
|
|
69
73
|
}
|
|
70
74
|
};
|
|
71
75
|
},
|
|
@@ -18,9 +18,11 @@ function InMemoryStorageCSFactory(params) {
|
|
|
18
18
|
var _a = params.settings, _b = _a.scheduler, impressionsQueueSize = _b.impressionsQueueSize, eventsQueueSize = _b.eventsQueueSize, _c = _a.sync, impressionsMode = _c.impressionsMode, __splitFiltersValidation = _c.__splitFiltersValidation;
|
|
19
19
|
var splits = new SplitsCacheInMemory_1.SplitsCacheInMemory(__splitFiltersValidation);
|
|
20
20
|
var segments = new MySegmentsCacheInMemory_1.MySegmentsCacheInMemory();
|
|
21
|
+
var largeSegments = new MySegmentsCacheInMemory_1.MySegmentsCacheInMemory();
|
|
21
22
|
var storage = {
|
|
22
23
|
splits: splits,
|
|
23
24
|
segments: segments,
|
|
25
|
+
largeSegments: largeSegments,
|
|
24
26
|
impressions: new ImpressionsCacheInMemory_1.ImpressionsCacheInMemory(impressionsQueueSize),
|
|
25
27
|
impressionCounts: impressionsMode !== constants_1.DEBUG ? new ImpressionCountsCacheInMemory_1.ImpressionCountsCacheInMemory() : undefined,
|
|
26
28
|
events: new EventsCacheInMemory_1.EventsCacheInMemory(eventsQueueSize),
|
|
@@ -30,6 +32,7 @@ function InMemoryStorageCSFactory(params) {
|
|
|
30
32
|
destroy: function () {
|
|
31
33
|
this.splits.clear();
|
|
32
34
|
this.segments.clear();
|
|
35
|
+
this.largeSegments.clear();
|
|
33
36
|
this.impressions.clear();
|
|
34
37
|
this.impressionCounts && this.impressionCounts.clear();
|
|
35
38
|
this.events.clear();
|
|
@@ -40,6 +43,7 @@ function InMemoryStorageCSFactory(params) {
|
|
|
40
43
|
return {
|
|
41
44
|
splits: this.splits,
|
|
42
45
|
segments: new MySegmentsCacheInMemory_1.MySegmentsCacheInMemory(),
|
|
46
|
+
largeSegments: new MySegmentsCacheInMemory_1.MySegmentsCacheInMemory(),
|
|
43
47
|
impressions: this.impressions,
|
|
44
48
|
impressionCounts: this.impressionCounts,
|
|
45
49
|
events: this.events,
|
|
@@ -48,6 +52,7 @@ function InMemoryStorageCSFactory(params) {
|
|
|
48
52
|
destroy: function () {
|
|
49
53
|
this.splits = new SplitsCacheInMemory_1.SplitsCacheInMemory(__splitFiltersValidation);
|
|
50
54
|
this.segments.clear();
|
|
55
|
+
this.largeSegments.clear();
|
|
51
56
|
}
|
|
52
57
|
};
|
|
53
58
|
},
|
|
@@ -14,57 +14,26 @@ var MySegmentsCacheInMemory = /** @class */ (function (_super) {
|
|
|
14
14
|
_this.segmentCache = {};
|
|
15
15
|
return _this;
|
|
16
16
|
}
|
|
17
|
-
MySegmentsCacheInMemory.prototype.clear = function () {
|
|
18
|
-
this.segmentCache = {};
|
|
19
|
-
};
|
|
20
17
|
MySegmentsCacheInMemory.prototype.addToSegment = function (name) {
|
|
18
|
+
if (this.segmentCache[name])
|
|
19
|
+
return false;
|
|
21
20
|
this.segmentCache[name] = true;
|
|
22
21
|
return true;
|
|
23
22
|
};
|
|
24
23
|
MySegmentsCacheInMemory.prototype.removeFromSegment = function (name) {
|
|
24
|
+
if (!this.segmentCache[name])
|
|
25
|
+
return false;
|
|
25
26
|
delete this.segmentCache[name];
|
|
26
27
|
return true;
|
|
27
28
|
};
|
|
28
29
|
MySegmentsCacheInMemory.prototype.isInSegment = function (name) {
|
|
29
30
|
return this.segmentCache[name] === true;
|
|
30
31
|
};
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
* @returns boolean indicating if the cache was updated (i.e., given list was different from the cached one)
|
|
37
|
-
*/
|
|
38
|
-
MySegmentsCacheInMemory.prototype.resetSegments = function (names) {
|
|
39
|
-
var _this = this;
|
|
40
|
-
var isDiff = false;
|
|
41
|
-
var index;
|
|
42
|
-
var storedSegmentKeys = Object.keys(this.segmentCache);
|
|
43
|
-
// Extreme fast => everything is empty
|
|
44
|
-
if (names.length === 0 && storedSegmentKeys.length === names.length)
|
|
45
|
-
return isDiff;
|
|
46
|
-
// Quick path
|
|
47
|
-
if (storedSegmentKeys.length !== names.length) {
|
|
48
|
-
isDiff = true;
|
|
49
|
-
this.segmentCache = {};
|
|
50
|
-
names.forEach(function (s) {
|
|
51
|
-
_this.addToSegment(s);
|
|
52
|
-
});
|
|
53
|
-
}
|
|
54
|
-
else {
|
|
55
|
-
// Slowest path => we need to find at least 1 difference because
|
|
56
|
-
for (index = 0; index < names.length && this.isInSegment(names[index]); index++) {
|
|
57
|
-
// TODO: why empty statement?
|
|
58
|
-
}
|
|
59
|
-
if (index < names.length) {
|
|
60
|
-
isDiff = true;
|
|
61
|
-
this.segmentCache = {};
|
|
62
|
-
names.forEach(function (s) {
|
|
63
|
-
_this.addToSegment(s);
|
|
64
|
-
});
|
|
65
|
-
}
|
|
66
|
-
}
|
|
67
|
-
return isDiff;
|
|
32
|
+
MySegmentsCacheInMemory.prototype.setChangeNumber = function (name, changeNumber) {
|
|
33
|
+
this.cn = changeNumber;
|
|
34
|
+
};
|
|
35
|
+
MySegmentsCacheInMemory.prototype.getChangeNumber = function () {
|
|
36
|
+
return this.cn || -1;
|
|
68
37
|
};
|
|
69
38
|
MySegmentsCacheInMemory.prototype.getRegisteredSegments = function () {
|
|
70
39
|
return Object.keys(this.segmentCache);
|
|
@@ -16,7 +16,7 @@ var SplitsCacheInMemory = /** @class */ (function (_super) {
|
|
|
16
16
|
_this.splitsCache = {};
|
|
17
17
|
_this.ttCache = {};
|
|
18
18
|
_this.changeNumber = -1;
|
|
19
|
-
_this.
|
|
19
|
+
_this.segmentsCount = 0;
|
|
20
20
|
_this.flagSetsCache = {};
|
|
21
21
|
_this.flagSetsFilter = splitFiltersValidation ? splitFiltersValidation.groupedFilters.bySet : [];
|
|
22
22
|
return _this;
|
|
@@ -25,7 +25,7 @@ var SplitsCacheInMemory = /** @class */ (function (_super) {
|
|
|
25
25
|
this.splitsCache = {};
|
|
26
26
|
this.ttCache = {};
|
|
27
27
|
this.changeNumber = -1;
|
|
28
|
-
this.
|
|
28
|
+
this.segmentsCount = 0;
|
|
29
29
|
};
|
|
30
30
|
SplitsCacheInMemory.prototype.addSplit = function (name, split) {
|
|
31
31
|
var previousSplit = this.getSplit(name);
|
|
@@ -35,9 +35,9 @@ var SplitsCacheInMemory = /** @class */ (function (_super) {
|
|
|
35
35
|
if (!this.ttCache[previousTtName])
|
|
36
36
|
delete this.ttCache[previousTtName];
|
|
37
37
|
this.removeFromFlagSets(previousSplit.name, previousSplit.sets);
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
38
|
+
// Subtract from segments count for the previous version of this Split
|
|
39
|
+
if ((0, AbstractSplitsCacheSync_1.usesSegments)(previousSplit))
|
|
40
|
+
this.segmentsCount--;
|
|
41
41
|
}
|
|
42
42
|
if (split) {
|
|
43
43
|
// Store the Split.
|
|
@@ -48,7 +48,7 @@ var SplitsCacheInMemory = /** @class */ (function (_super) {
|
|
|
48
48
|
this.addToFlagSets(split);
|
|
49
49
|
// Add to segments count for the new version of the Split
|
|
50
50
|
if ((0, AbstractSplitsCacheSync_1.usesSegments)(split))
|
|
51
|
-
this.
|
|
51
|
+
this.segmentsCount++;
|
|
52
52
|
return true;
|
|
53
53
|
}
|
|
54
54
|
else {
|
|
@@ -67,7 +67,7 @@ var SplitsCacheInMemory = /** @class */ (function (_super) {
|
|
|
67
67
|
this.removeFromFlagSets(split.name, split.sets);
|
|
68
68
|
// Update the segments count.
|
|
69
69
|
if ((0, AbstractSplitsCacheSync_1.usesSegments)(split))
|
|
70
|
-
this.
|
|
70
|
+
this.segmentsCount--;
|
|
71
71
|
return true;
|
|
72
72
|
}
|
|
73
73
|
else {
|
|
@@ -91,7 +91,7 @@ var SplitsCacheInMemory = /** @class */ (function (_super) {
|
|
|
91
91
|
return (0, lang_1.isFiniteNumber)(this.ttCache[trafficType]) && this.ttCache[trafficType] > 0;
|
|
92
92
|
};
|
|
93
93
|
SplitsCacheInMemory.prototype.usesSegments = function () {
|
|
94
|
-
return this.getChangeNumber() === -1 || this.
|
|
94
|
+
return this.getChangeNumber() === -1 || this.segmentsCount > 0;
|
|
95
95
|
};
|
|
96
96
|
SplitsCacheInMemory.prototype.getNamesByFlagSets = function (flagSets) {
|
|
97
97
|
var _this = this;
|
|
@@ -23,9 +23,10 @@ function shouldRecordTelemetry(_a) {
|
|
|
23
23
|
}
|
|
24
24
|
exports.shouldRecordTelemetry = shouldRecordTelemetry;
|
|
25
25
|
var TelemetryCacheInMemory = /** @class */ (function () {
|
|
26
|
-
function TelemetryCacheInMemory(splits, segments) {
|
|
26
|
+
function TelemetryCacheInMemory(splits, segments, largeSegments) {
|
|
27
27
|
this.splits = splits;
|
|
28
28
|
this.segments = segments;
|
|
29
|
+
this.largeSegments = largeSegments;
|
|
29
30
|
// isEmpty flag
|
|
30
31
|
this.e = true;
|
|
31
32
|
this.notReadyUsage = 0;
|
|
@@ -41,10 +42,7 @@ var TelemetryCacheInMemory = /** @class */ (function () {
|
|
|
41
42
|
this.tags = [];
|
|
42
43
|
this.exceptions = {};
|
|
43
44
|
this.latencies = {};
|
|
44
|
-
this.updatesFromSSE = {
|
|
45
|
-
sp: 0,
|
|
46
|
-
ms: 0
|
|
47
|
-
};
|
|
45
|
+
this.updatesFromSSE = {};
|
|
48
46
|
}
|
|
49
47
|
TelemetryCacheInMemory.prototype.isEmpty = function () { return this.e; };
|
|
50
48
|
TelemetryCacheInMemory.prototype.clear = function () { };
|
|
@@ -64,6 +62,8 @@ var TelemetryCacheInMemory = /** @class */ (function () {
|
|
|
64
62
|
spC: this.splits && this.splits.getSplitNames().length,
|
|
65
63
|
seC: this.segments && this.segments.getRegisteredSegments().length,
|
|
66
64
|
skC: this.segments && this.segments.getKeysCount(),
|
|
65
|
+
lsC: this.largeSegments && this.largeSegments.getRegisteredSegments().length,
|
|
66
|
+
lskC: this.largeSegments && this.largeSegments.getKeysCount(),
|
|
67
67
|
sL: this.getSessionLength(),
|
|
68
68
|
eQ: this.getEventStats(constants_1.QUEUED),
|
|
69
69
|
eD: this.getEventStats(constants_1.DROPPED),
|
|
@@ -195,14 +195,11 @@ var TelemetryCacheInMemory = /** @class */ (function () {
|
|
|
195
195
|
};
|
|
196
196
|
TelemetryCacheInMemory.prototype.popUpdatesFromSSE = function () {
|
|
197
197
|
var result = this.updatesFromSSE;
|
|
198
|
-
this.updatesFromSSE = {
|
|
199
|
-
sp: 0,
|
|
200
|
-
ms: 0,
|
|
201
|
-
};
|
|
198
|
+
this.updatesFromSSE = {};
|
|
202
199
|
return result;
|
|
203
200
|
};
|
|
204
201
|
TelemetryCacheInMemory.prototype.recordUpdatesFromSSE = function (type) {
|
|
205
|
-
this.updatesFromSSE[type]
|
|
202
|
+
this.updatesFromSSE[type] = (this.updatesFromSSE[type] || 0) + 1;
|
|
206
203
|
this.e = false;
|
|
207
204
|
};
|
|
208
205
|
return TelemetryCacheInMemory;
|
|
@@ -8,7 +8,7 @@ var sets_1 = require("../../utils/lang/sets");
|
|
|
8
8
|
* The `_cache` property is the object were items are stored.
|
|
9
9
|
* Intended for testing purposes.
|
|
10
10
|
*
|
|
11
|
-
* @param connDelay delay in millis for `connect` resolve. If not provided, `connect` resolves
|
|
11
|
+
* @param connDelay delay in millis for `connect` resolve. If not provided, `connect` resolves immediately.
|
|
12
12
|
*/
|
|
13
13
|
function inMemoryWrapperFactory(connDelay) {
|
|
14
14
|
var _cache = {};
|
|
@@ -5,17 +5,14 @@ exports.mySegmentsFetcherFactory = void 0;
|
|
|
5
5
|
* Factory of MySegments fetcher.
|
|
6
6
|
* MySegments fetcher is a wrapper around `mySegments` API service that parses the response and handle errors.
|
|
7
7
|
*/
|
|
8
|
-
function mySegmentsFetcherFactory(
|
|
9
|
-
return function mySegmentsFetcher(userMatchingKey, noCache,
|
|
10
|
-
// Optional decorator for `
|
|
8
|
+
function mySegmentsFetcherFactory(fetchMemberships) {
|
|
9
|
+
return function mySegmentsFetcher(userMatchingKey, noCache, till,
|
|
10
|
+
// Optional decorator for `fetchMemberships` promise, such as timeout or time tracker
|
|
11
11
|
decorator) {
|
|
12
|
-
var mySegmentsPromise =
|
|
12
|
+
var mySegmentsPromise = fetchMemberships(userMatchingKey, noCache, till);
|
|
13
13
|
if (decorator)
|
|
14
14
|
mySegmentsPromise = decorator(mySegmentsPromise);
|
|
15
|
-
|
|
16
|
-
return mySegmentsPromise
|
|
17
|
-
.then(function (resp) { return resp.json(); })
|
|
18
|
-
.then(function (json) { return json.mySegments.map(function (segment) { return segment.name; }); });
|
|
15
|
+
return mySegmentsPromise.then(function (resp) { return resp.json(); });
|
|
19
16
|
};
|
|
20
17
|
}
|
|
21
18
|
exports.mySegmentsFetcherFactory = mySegmentsFetcherFactory;
|
|
@@ -23,7 +23,7 @@ function greedyFetch(fetchSegmentChanges, since, segmentName, noCache, targetTil
|
|
|
23
23
|
*/
|
|
24
24
|
function segmentChangesFetcherFactory(fetchSegmentChanges) {
|
|
25
25
|
return function segmentChangesFetcher(since, segmentName, noCache, till,
|
|
26
|
-
// Optional decorator for `
|
|
26
|
+
// Optional decorator for `fetchSegmentChanges` promise, such as timeout or time tracker
|
|
27
27
|
decorator) {
|
|
28
28
|
var segmentsPromise = greedyFetch(fetchSegmentChanges, since, segmentName, noCache, till);
|
|
29
29
|
if (decorator)
|
|
@@ -46,7 +46,7 @@ function pollingManagerCSFactory(params) {
|
|
|
46
46
|
}
|
|
47
47
|
});
|
|
48
48
|
function add(matchingKey, readiness, storage) {
|
|
49
|
-
var mySegmentsSyncTask = (0, mySegmentsSyncTask_1.mySegmentsSyncTaskFactory)(splitApi.
|
|
49
|
+
var mySegmentsSyncTask = (0, mySegmentsSyncTask_1.mySegmentsSyncTaskFactory)(splitApi.fetchMemberships, storage, readiness, settings, matchingKey);
|
|
50
50
|
// smart ready
|
|
51
51
|
function smartReady() {
|
|
52
52
|
if (!readiness.isReady() && !storage.splits.usesSegments())
|
|
@@ -7,7 +7,7 @@ var mySegmentsUpdater_1 = require("../updaters/mySegmentsUpdater");
|
|
|
7
7
|
/**
|
|
8
8
|
* Creates a sync task that periodically executes a `mySegmentsUpdater` task
|
|
9
9
|
*/
|
|
10
|
-
function mySegmentsSyncTaskFactory(
|
|
11
|
-
return (0, syncTask_1.syncTaskFactory)(settings.log, (0, mySegmentsUpdater_1.mySegmentsUpdaterFactory)(settings.log, (0, mySegmentsFetcher_1.mySegmentsFetcherFactory)(
|
|
10
|
+
function mySegmentsSyncTaskFactory(fetchMemberships, storage, readiness, settings, matchingKey) {
|
|
11
|
+
return (0, syncTask_1.syncTaskFactory)(settings.log, (0, mySegmentsUpdater_1.mySegmentsUpdaterFactory)(settings.log, (0, mySegmentsFetcher_1.mySegmentsFetcherFactory)(fetchMemberships), storage, readiness.segments, settings.startup.requestTimeoutBeforeReady, settings.startup.retriesOnFailureBeforeReady, matchingKey), settings.scheduler.segmentsRefreshRate, 'mySegmentsUpdater');
|
|
12
12
|
}
|
|
13
13
|
exports.mySegmentsSyncTaskFactory = mySegmentsSyncTaskFactory;
|
|
@@ -4,13 +4,15 @@ exports.mySegmentsUpdaterFactory = void 0;
|
|
|
4
4
|
var timeout_1 = require("../../../utils/promise/timeout");
|
|
5
5
|
var constants_1 = require("../../../readiness/constants");
|
|
6
6
|
var constants_2 = require("../../../logger/constants");
|
|
7
|
+
var constants_3 = require("../../streaming/constants");
|
|
7
8
|
/**
|
|
8
9
|
* factory of MySegments updater, a task that:
|
|
9
10
|
* - fetches mySegments using `mySegmentsFetcher`
|
|
10
11
|
* - updates `mySegmentsCache`
|
|
11
12
|
* - uses `segmentsEventEmitter` to emit events related to segments data updates
|
|
12
13
|
*/
|
|
13
|
-
function mySegmentsUpdaterFactory(log, mySegmentsFetcher,
|
|
14
|
+
function mySegmentsUpdaterFactory(log, mySegmentsFetcher, storage, segmentsEventEmitter, requestTimeoutBeforeReady, retriesOnFailureBeforeReady, matchingKey) {
|
|
15
|
+
var splits = storage.splits, segments = storage.segments, largeSegments = storage.largeSegments;
|
|
14
16
|
var readyOnAlreadyExistentState = true;
|
|
15
17
|
var startingUp = true;
|
|
16
18
|
/** timeout and telemetry decorator for `splitChangesFetcher` promise */
|
|
@@ -22,36 +24,27 @@ function mySegmentsUpdaterFactory(log, mySegmentsFetcher, splitsCache, mySegment
|
|
|
22
24
|
// @TODO if allowing pluggable storages, handle async execution
|
|
23
25
|
function updateSegments(segmentsData) {
|
|
24
26
|
var shouldNotifyUpdate;
|
|
25
|
-
if (
|
|
26
|
-
|
|
27
|
-
|
|
27
|
+
if (segmentsData.type !== undefined) {
|
|
28
|
+
shouldNotifyUpdate = segmentsData.type === constants_3.MEMBERSHIPS_LS_UPDATE ?
|
|
29
|
+
largeSegments.resetSegments(segmentsData) :
|
|
30
|
+
segments.resetSegments(segmentsData);
|
|
28
31
|
}
|
|
29
32
|
else {
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
if (mySegmentsCache.isInSegment(name_1) !== add) {
|
|
33
|
-
shouldNotifyUpdate = true;
|
|
34
|
-
if (add)
|
|
35
|
-
mySegmentsCache.addToSegment(name_1);
|
|
36
|
-
else
|
|
37
|
-
mySegmentsCache.removeFromSegment(name_1);
|
|
38
|
-
}
|
|
39
|
-
else {
|
|
40
|
-
shouldNotifyUpdate = false;
|
|
41
|
-
}
|
|
33
|
+
shouldNotifyUpdate = segments.resetSegments(segmentsData.ms || {});
|
|
34
|
+
shouldNotifyUpdate = largeSegments.resetSegments(segmentsData.ls || {}) || shouldNotifyUpdate;
|
|
42
35
|
}
|
|
43
36
|
// Notify update if required
|
|
44
|
-
if (
|
|
37
|
+
if (splits.usesSegments() && (shouldNotifyUpdate || readyOnAlreadyExistentState)) {
|
|
45
38
|
readyOnAlreadyExistentState = false;
|
|
46
39
|
segmentsEventEmitter.emit(constants_1.SDK_SEGMENTS_ARRIVED);
|
|
47
40
|
}
|
|
48
41
|
}
|
|
49
|
-
function _mySegmentsUpdater(retry, segmentsData, noCache) {
|
|
42
|
+
function _mySegmentsUpdater(retry, segmentsData, noCache, till) {
|
|
50
43
|
var updaterPromise = segmentsData ?
|
|
51
44
|
// If segmentsData is provided, there is no need to fetch mySegments
|
|
52
45
|
new Promise(function (res) { updateSegments(segmentsData); res(true); }) :
|
|
53
46
|
// If not provided, fetch mySegments
|
|
54
|
-
mySegmentsFetcher(matchingKey, noCache, _promiseDecorator).then(function (segments) {
|
|
47
|
+
mySegmentsFetcher(matchingKey, noCache, till, _promiseDecorator).then(function (segments) {
|
|
55
48
|
// Only when we have downloaded segments completely, we should not keep retrying anymore
|
|
56
49
|
startingUp = false;
|
|
57
50
|
updateSegments(segments);
|
|
@@ -78,9 +71,10 @@ function mySegmentsUpdaterFactory(log, mySegmentsFetcher, splitsCache, mySegment
|
|
|
78
71
|
* (2) an object with a segment name and action (true: add, or false: delete) to update the storage,
|
|
79
72
|
* (3) or `undefined`, for which the updater will fetch mySegments in order to sync the storage.
|
|
80
73
|
* @param {boolean | undefined} noCache true to revalidate data to fetch
|
|
74
|
+
* @param {boolean | undefined} till query param to bypass CDN requests
|
|
81
75
|
*/
|
|
82
|
-
return function mySegmentsUpdater(segmentsData, noCache) {
|
|
83
|
-
return _mySegmentsUpdater(0, segmentsData, noCache);
|
|
76
|
+
return function mySegmentsUpdater(segmentsData, noCache, till) {
|
|
77
|
+
return _mySegmentsUpdater(0, segmentsData, noCache, till);
|
|
84
78
|
};
|
|
85
79
|
}
|
|
86
80
|
exports.mySegmentsUpdaterFactory = mySegmentsUpdaterFactory;
|
|
@@ -13,7 +13,7 @@ var murmur3_1 = require("../../../utils/murmur3/murmur3");
|
|
|
13
13
|
function authenticateFactory(fetchAuth) {
|
|
14
14
|
/**
|
|
15
15
|
* Run authentication requests to Auth Server, and returns a promise that resolves with the decoded JTW token.
|
|
16
|
-
* @param {string[] | undefined} userKeys set of user Keys to track
|
|
16
|
+
* @param {string[] | undefined} userKeys set of user Keys to track membership updates. It is undefined for server-side API.
|
|
17
17
|
*/
|
|
18
18
|
return function authenticate(userKeys) {
|
|
19
19
|
return fetchAuth(userKeys)
|
|
@@ -68,20 +68,18 @@ function SSEHandlerFactory(log, pushEmitter, telemetryTracker) {
|
|
|
68
68
|
}
|
|
69
69
|
var parsedData = messageWithParsedData.parsedData, data = messageWithParsedData.data, channel = messageWithParsedData.channel, timestamp = messageWithParsedData.timestamp;
|
|
70
70
|
log.debug(constants_2.STREAMING_NEW_MESSAGE, [data]);
|
|
71
|
-
// we only handle update events if streaming is up
|
|
71
|
+
// we only handle update events if streaming is up
|
|
72
72
|
if (!notificationKeeper.isStreamingUp() && [constants_1.OCCUPANCY, constants_1.CONTROL].indexOf(parsedData.type) === -1)
|
|
73
73
|
return;
|
|
74
74
|
switch (parsedData.type) {
|
|
75
75
|
/* update events */
|
|
76
76
|
case constants_1.SPLIT_UPDATE:
|
|
77
77
|
case constants_1.SEGMENT_UPDATE:
|
|
78
|
-
case constants_1.
|
|
78
|
+
case constants_1.MEMBERSHIPS_MS_UPDATE:
|
|
79
|
+
case constants_1.MEMBERSHIPS_LS_UPDATE:
|
|
79
80
|
case constants_1.SPLIT_KILL:
|
|
80
81
|
pushEmitter.emit(parsedData.type, parsedData);
|
|
81
82
|
break;
|
|
82
|
-
case constants_1.MY_SEGMENTS_UPDATE:
|
|
83
|
-
pushEmitter.emit(parsedData.type, parsedData, channel);
|
|
84
|
-
break;
|
|
85
83
|
/* occupancy & control events, handled by NotificationManagerKeeper */
|
|
86
84
|
case constants_1.OCCUPANCY:
|
|
87
85
|
notificationKeeper.handleOccupancyEvent(parsedData.metrics.publishers, channel, timestamp);
|