@splitsoftware/splitio-commons 1.16.1-rc.10 → 1.16.1-rc.12
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/cjs/logger/constants.js +2 -2
- package/cjs/logger/messages/warn.js +1 -1
- package/cjs/services/splitApi.js +3 -3
- package/cjs/storages/AbstractSegmentsCacheSync.js +41 -7
- package/cjs/storages/dataLoader.js +1 -1
- package/cjs/storages/inLocalStorage/MySegmentsCacheInLocal.js +19 -63
- package/cjs/storages/inMemory/MySegmentsCacheInMemory.js +5 -40
- package/cjs/storages/inMemory/TelemetryCacheInMemory.js +1 -1
- package/cjs/sync/polling/fetchers/mySegmentsFetcher.js +2 -2
- package/cjs/sync/polling/updaters/mySegmentsUpdater.js +12 -21
- package/cjs/sync/streaming/AuthClient/index.js +1 -1
- package/cjs/sync/streaming/SSEHandler/index.js +5 -7
- package/cjs/sync/streaming/UpdateWorkers/MySegmentsUpdateWorker.js +106 -63
- package/cjs/sync/streaming/constants.js +3 -3
- package/cjs/sync/streaming/pushManager.js +25 -31
- package/cjs/utils/constants/index.js +3 -4
- package/esm/logger/constants.js +1 -1
- package/esm/logger/messages/warn.js +1 -1
- package/esm/services/splitApi.js +4 -4
- package/esm/storages/AbstractSegmentsCacheSync.js +41 -7
- package/esm/storages/dataLoader.js +1 -1
- package/esm/storages/inLocalStorage/MySegmentsCacheInLocal.js +19 -63
- package/esm/storages/inMemory/MySegmentsCacheInMemory.js +5 -40
- package/esm/storages/inMemory/TelemetryCacheInMemory.js +1 -1
- package/esm/sync/polling/fetchers/mySegmentsFetcher.js +2 -2
- package/esm/sync/polling/updaters/mySegmentsUpdater.js +12 -21
- package/esm/sync/streaming/AuthClient/index.js +1 -1
- package/esm/sync/streaming/SSEHandler/index.js +6 -8
- package/esm/sync/streaming/UpdateWorkers/MySegmentsUpdateWorker.js +106 -63
- package/esm/sync/streaming/constants.js +2 -2
- package/esm/sync/streaming/pushManager.js +28 -34
- package/esm/utils/constants/index.js +1 -2
- package/package.json +1 -1
- package/src/dtos/types.ts +9 -12
- package/src/logger/constants.ts +1 -1
- package/src/logger/messages/warn.ts +1 -1
- package/src/services/splitApi.ts +4 -4
- package/src/services/types.ts +1 -1
- package/src/storages/AbstractSegmentsCacheSync.ts +52 -7
- package/src/storages/AbstractSplitsCacheSync.ts +1 -1
- package/src/storages/dataLoader.ts +1 -1
- package/src/storages/inLocalStorage/MySegmentsCacheInLocal.ts +15 -69
- package/src/storages/inMemory/MySegmentsCacheInMemory.ts +6 -46
- package/src/storages/inMemory/TelemetryCacheInMemory.ts +1 -1
- package/src/storages/types.ts +6 -5
- package/src/sync/polling/fetchers/mySegmentsFetcher.ts +2 -1
- package/src/sync/polling/fetchers/types.ts +1 -0
- package/src/sync/polling/types.ts +9 -10
- package/src/sync/polling/updaters/mySegmentsUpdater.ts +15 -19
- package/src/sync/streaming/AuthClient/index.ts +1 -1
- package/src/sync/streaming/SSEHandler/index.ts +9 -11
- package/src/sync/streaming/SSEHandler/types.ts +6 -6
- package/src/sync/streaming/UpdateWorkers/MySegmentsUpdateWorker.ts +114 -65
- package/src/sync/streaming/constants.ts +2 -2
- package/src/sync/streaming/parseUtils.ts +2 -2
- package/src/sync/streaming/pushManager.ts +30 -39
- package/src/sync/streaming/types.ts +6 -6
- package/src/sync/submitters/types.ts +4 -5
- package/src/utils/constants/index.ts +1 -2
- package/types/dtos/types.d.ts +8 -12
- package/types/logger/constants.d.ts +1 -1
- package/types/services/types.d.ts +1 -1
- package/types/storages/AbstractSegmentsCacheSync.d.ts +8 -6
- package/types/storages/AbstractSplitsCacheSync.d.ts +1 -1
- package/types/storages/inLocalStorage/MySegmentsCacheInLocal.d.ts +1 -12
- package/types/storages/inMemory/MySegmentsCacheInMemory.d.ts +1 -9
- package/types/storages/types.d.ts +6 -5
- package/types/sync/polling/fetchers/types.d.ts +1 -1
- package/types/sync/polling/types.d.ts +9 -7
- package/types/sync/polling/updaters/mySegmentsUpdater.d.ts +1 -1
- package/types/sync/streaming/SSEHandler/types.d.ts +6 -6
- package/types/sync/streaming/UpdateWorkers/MySegmentsUpdateWorker.d.ts +3 -2
- package/types/sync/streaming/constants.d.ts +2 -2
- package/types/sync/streaming/parseUtils.d.ts +2 -2
- package/types/sync/streaming/types.d.ts +5 -5
- package/types/sync/submitters/types.d.ts +4 -5
- package/types/utils/constants/index.d.ts +1 -2
|
@@ -1,6 +1,7 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { ISplit } from '../../dtos/types';
|
|
2
2
|
import { IReadinessManager } from '../../readiness/types';
|
|
3
3
|
import { IStorageSync } from '../../storages/types';
|
|
4
|
+
import { MEMBERSHIPS_LS_UPDATE, MEMBERSHIPS_MS_UPDATE } from '../streaming/types';
|
|
4
5
|
import { ITask, ISyncTask } from '../types';
|
|
5
6
|
export interface ISplitsSyncTask extends ISyncTask<[noCache?: boolean, till?: number, splitUpdateNotification?: {
|
|
6
7
|
payload: ISplit;
|
|
@@ -9,12 +10,13 @@ export interface ISplitsSyncTask extends ISyncTask<[noCache?: boolean, till?: nu
|
|
|
9
10
|
}
|
|
10
11
|
export interface ISegmentsSyncTask extends ISyncTask<[fetchOnlyNew?: boolean, segmentName?: string, noCache?: boolean, till?: number], boolean> {
|
|
11
12
|
}
|
|
12
|
-
export declare type MySegmentsData =
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
13
|
+
export declare type MySegmentsData = {
|
|
14
|
+
type: MEMBERSHIPS_MS_UPDATE | MEMBERSHIPS_LS_UPDATE;
|
|
15
|
+
cn: number;
|
|
16
|
+
added: string[];
|
|
17
|
+
removed: string[];
|
|
18
|
+
};
|
|
19
|
+
export interface IMySegmentsSyncTask extends ISyncTask<[segmentsData?: MySegmentsData, noCache?: boolean, till?: number], boolean> {
|
|
18
20
|
}
|
|
19
21
|
export interface IPollingManager extends ITask {
|
|
20
22
|
syncAll(): Promise<any>;
|
|
@@ -3,7 +3,7 @@ import { IStorageSync } from '../../../storages/types';
|
|
|
3
3
|
import { ISegmentsEventEmitter } from '../../../readiness/types';
|
|
4
4
|
import { ILogger } from '../../../logger/types';
|
|
5
5
|
import { MySegmentsData } from '../types';
|
|
6
|
-
declare type IMySegmentsUpdater = (
|
|
6
|
+
declare type IMySegmentsUpdater = (segmentsData?: MySegmentsData, noCache?: boolean, till?: number) => Promise<boolean>;
|
|
7
7
|
/**
|
|
8
8
|
* factory of MySegments updater, a task that:
|
|
9
9
|
* - fetches mySegments using `mySegmentsFetcher`
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { ControlType } from '../constants';
|
|
2
|
-
import { SEGMENT_UPDATE, SPLIT_UPDATE, SPLIT_KILL, CONTROL, OCCUPANCY,
|
|
2
|
+
import { SEGMENT_UPDATE, SPLIT_UPDATE, SPLIT_KILL, CONTROL, OCCUPANCY, MEMBERSHIPS_LS_UPDATE, MEMBERSHIPS_MS_UPDATE } from '../types';
|
|
3
3
|
export declare enum Compression {
|
|
4
4
|
None = 0,
|
|
5
5
|
Gzip = 1,
|
|
@@ -15,8 +15,8 @@ export interface KeyList {
|
|
|
15
15
|
a?: string[];
|
|
16
16
|
r?: string[];
|
|
17
17
|
}
|
|
18
|
-
interface
|
|
19
|
-
|
|
18
|
+
interface IMembershipUpdateData<T extends string> {
|
|
19
|
+
type: T;
|
|
20
20
|
cn: number;
|
|
21
21
|
n?: string[];
|
|
22
22
|
c?: Compression;
|
|
@@ -26,9 +26,9 @@ interface IMySegmentsUpdateData<T extends string> {
|
|
|
26
26
|
h?: number;
|
|
27
27
|
s?: number;
|
|
28
28
|
}
|
|
29
|
-
export interface
|
|
29
|
+
export interface IMembershipMSUpdateData extends IMembershipUpdateData<MEMBERSHIPS_MS_UPDATE> {
|
|
30
30
|
}
|
|
31
|
-
export interface
|
|
31
|
+
export interface IMembershipLSUpdateData extends IMembershipUpdateData<MEMBERSHIPS_LS_UPDATE> {
|
|
32
32
|
}
|
|
33
33
|
export interface ISegmentUpdateData {
|
|
34
34
|
type: SEGMENT_UPDATE;
|
|
@@ -58,7 +58,7 @@ export interface IOccupancyData {
|
|
|
58
58
|
publishers: number;
|
|
59
59
|
};
|
|
60
60
|
}
|
|
61
|
-
export declare type INotificationData =
|
|
61
|
+
export declare type INotificationData = IMembershipMSUpdateData | IMembershipLSUpdateData | ISegmentUpdateData | ISplitUpdateData | ISplitKillData | IControlData | IOccupancyData;
|
|
62
62
|
export declare type INotificationMessage = {
|
|
63
63
|
parsedData: INotificationData;
|
|
64
64
|
channel: string;
|
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
import { IMySegmentsSyncTask, MySegmentsData } from '../../polling/types';
|
|
2
2
|
import { IUpdateWorker } from './types';
|
|
3
3
|
import { ITelemetryTracker } from '../../../trackers/types';
|
|
4
|
-
import {
|
|
4
|
+
import { IStorageSync } from '../../../storages/types';
|
|
5
|
+
import { ILogger } from '../../../logger/types';
|
|
5
6
|
/**
|
|
6
7
|
* MySegmentsUpdateWorker factory
|
|
7
8
|
*/
|
|
8
|
-
export declare function MySegmentsUpdateWorker(mySegmentsSyncTask: IMySegmentsSyncTask, telemetryTracker: ITelemetryTracker
|
|
9
|
+
export declare function MySegmentsUpdateWorker(log: ILogger, storage: Pick<IStorageSync, 'segments' | 'largeSegments'>, mySegmentsSyncTask: IMySegmentsSyncTask, telemetryTracker: ITelemetryTracker): IUpdateWorker<[mySegmentsData?: Pick<MySegmentsData, 'type' | 'cn'>, payload?: Pick<MySegmentsData, 'added' | 'removed'>, delay?: number]>;
|
|
@@ -19,11 +19,11 @@ export declare const PUSH_SUBSYSTEM_UP = "PUSH_SUBSYSTEM_UP";
|
|
|
19
19
|
* triggers `startPolling` and `stopWorkers` calls
|
|
20
20
|
*/
|
|
21
21
|
export declare const PUSH_SUBSYSTEM_DOWN = "PUSH_SUBSYSTEM_DOWN";
|
|
22
|
-
export declare const
|
|
22
|
+
export declare const MEMBERSHIPS_MS_UPDATE = "MEMBERSHIPS_MS_UPDATE";
|
|
23
|
+
export declare const MEMBERSHIPS_LS_UPDATE = "MEMBERSHIPS_LS_UPDATE";
|
|
23
24
|
export declare const SEGMENT_UPDATE = "SEGMENT_UPDATE";
|
|
24
25
|
export declare const SPLIT_KILL = "SPLIT_KILL";
|
|
25
26
|
export declare const SPLIT_UPDATE = "SPLIT_UPDATE";
|
|
26
|
-
export declare const MY_LARGE_SEGMENTS_UPDATE = "MY_LARGE_SEGMENTS_UPDATE";
|
|
27
27
|
export declare const CONTROL = "CONTROL";
|
|
28
28
|
export declare const OCCUPANCY = "OCCUPANCY";
|
|
29
29
|
export declare enum ControlType {
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { Compression,
|
|
1
|
+
import { Compression, IMembershipMSUpdateData, KeyList } from './SSEHandler/types';
|
|
2
2
|
import { ISplit } from '../../dtos/types';
|
|
3
3
|
/**
|
|
4
4
|
* Decode, decompress and parse the provided 'data' into a KeyList object
|
|
@@ -31,4 +31,4 @@ export declare function isInBitmap(bitmap: Uint8Array, hash64hex: string): boole
|
|
|
31
31
|
* Parse feature flags notifications for instant feature flag updates
|
|
32
32
|
*/
|
|
33
33
|
export declare function parseFFUpdatePayload(compression: Compression, data: string): ISplit | undefined;
|
|
34
|
-
export declare function getDelay(parsedData: Pick<
|
|
34
|
+
export declare function getDelay(parsedData: Pick<IMembershipMSUpdateData, 'i' | 'h' | 's'>, matchingKey: string): number;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { IMembershipMSUpdateData, IMembershipLSUpdateData, ISegmentUpdateData, ISplitUpdateData, ISplitKillData, INotificationData } from './SSEHandler/types';
|
|
2
2
|
import { ITask } from '../types';
|
|
3
3
|
import { IMySegmentsSyncTask } from '../polling/types';
|
|
4
4
|
import { IEventEmitter } from '../../types';
|
|
@@ -7,15 +7,15 @@ export declare type PUSH_SUBSYSTEM_UP = 'PUSH_SUBSYSTEM_UP';
|
|
|
7
7
|
export declare type PUSH_SUBSYSTEM_DOWN = 'PUSH_SUBSYSTEM_DOWN';
|
|
8
8
|
export declare type PUSH_NONRETRYABLE_ERROR = 'PUSH_NONRETRYABLE_ERROR';
|
|
9
9
|
export declare type PUSH_RETRYABLE_ERROR = 'PUSH_RETRYABLE_ERROR';
|
|
10
|
-
export declare type
|
|
10
|
+
export declare type MEMBERSHIPS_MS_UPDATE = 'MEMBERSHIPS_MS_UPDATE';
|
|
11
|
+
export declare type MEMBERSHIPS_LS_UPDATE = 'MEMBERSHIPS_LS_UPDATE';
|
|
11
12
|
export declare type SEGMENT_UPDATE = 'SEGMENT_UPDATE';
|
|
12
13
|
export declare type SPLIT_KILL = 'SPLIT_KILL';
|
|
13
14
|
export declare type SPLIT_UPDATE = 'SPLIT_UPDATE';
|
|
14
|
-
export declare type MY_LARGE_SEGMENTS_UPDATE = 'MY_LARGE_SEGMENTS_UPDATE';
|
|
15
15
|
export declare type CONTROL = 'CONTROL';
|
|
16
16
|
export declare type OCCUPANCY = 'OCCUPANCY';
|
|
17
|
-
export declare type IPushEvent = PUSH_SUBSYSTEM_UP | PUSH_SUBSYSTEM_DOWN | PUSH_NONRETRYABLE_ERROR | PUSH_RETRYABLE_ERROR |
|
|
18
|
-
declare type IParsedData<T extends IPushEvent> = T extends
|
|
17
|
+
export declare type IPushEvent = PUSH_SUBSYSTEM_UP | PUSH_SUBSYSTEM_DOWN | PUSH_NONRETRYABLE_ERROR | PUSH_RETRYABLE_ERROR | MEMBERSHIPS_MS_UPDATE | MEMBERSHIPS_LS_UPDATE | SEGMENT_UPDATE | SPLIT_UPDATE | SPLIT_KILL | ControlType.STREAMING_RESET;
|
|
18
|
+
declare type IParsedData<T extends IPushEvent> = T extends MEMBERSHIPS_MS_UPDATE ? IMembershipMSUpdateData : T extends MEMBERSHIPS_LS_UPDATE ? IMembershipLSUpdateData : T extends SEGMENT_UPDATE ? ISegmentUpdateData : T extends SPLIT_UPDATE ? ISplitUpdateData : T extends SPLIT_KILL ? ISplitKillData : INotificationData;
|
|
19
19
|
/**
|
|
20
20
|
* EventEmitter used as Feedback Loop between the SyncManager and PushManager,
|
|
21
21
|
* where the latter pushes messages and the former consumes it
|
|
@@ -90,7 +90,7 @@ export declare type DROPPED = 1;
|
|
|
90
90
|
export declare type DEDUPED = 2;
|
|
91
91
|
export declare type ImpressionDataType = QUEUED | DROPPED | DEDUPED;
|
|
92
92
|
export declare type EventDataType = QUEUED | DROPPED;
|
|
93
|
-
export declare type UpdatesFromSSEEnum = SPLITS |
|
|
93
|
+
export declare type UpdatesFromSSEEnum = SPLITS | MEMBERSHIPS;
|
|
94
94
|
export declare type SPLITS = 'sp';
|
|
95
95
|
export declare type IMPRESSIONS = 'im';
|
|
96
96
|
export declare type IMPRESSIONS_COUNT = 'ic';
|
|
@@ -98,9 +98,8 @@ export declare type EVENTS = 'ev';
|
|
|
98
98
|
export declare type TELEMETRY = 'te';
|
|
99
99
|
export declare type TOKEN = 'to';
|
|
100
100
|
export declare type SEGMENT = 'se';
|
|
101
|
-
export declare type
|
|
102
|
-
export declare type
|
|
103
|
-
export declare type OperationType = SPLITS | IMPRESSIONS | IMPRESSIONS_COUNT | EVENTS | TELEMETRY | TOKEN | SEGMENT | MY_SEGMENT;
|
|
101
|
+
export declare type MEMBERSHIPS = 'ms';
|
|
102
|
+
export declare type OperationType = SPLITS | IMPRESSIONS | IMPRESSIONS_COUNT | EVENTS | TELEMETRY | TOKEN | SEGMENT | MEMBERSHIPS;
|
|
104
103
|
export declare type LastSync = Partial<Record<OperationType, number | undefined>>;
|
|
105
104
|
export declare type HttpErrors = Partial<Record<OperationType, {
|
|
106
105
|
[statusCode: string]: number;
|
|
@@ -153,7 +152,7 @@ export declare type TelemetryUsageStatsPayload = TelemetryUsageStats & {
|
|
|
153
152
|
spC?: number;
|
|
154
153
|
seC?: number;
|
|
155
154
|
skC?: number;
|
|
156
|
-
|
|
155
|
+
lsC?: number;
|
|
157
156
|
lskC?: number;
|
|
158
157
|
sL?: number;
|
|
159
158
|
eQ: number;
|
|
@@ -52,8 +52,7 @@ export declare const EVENTS = "ev";
|
|
|
52
52
|
export declare const TELEMETRY = "te";
|
|
53
53
|
export declare const TOKEN = "to";
|
|
54
54
|
export declare const SEGMENT = "se";
|
|
55
|
-
export declare const
|
|
56
|
-
export declare const MY_LARGE_SEGMENT = "mls";
|
|
55
|
+
export declare const MEMBERSHIPS = "ms";
|
|
57
56
|
export declare const TREATMENT = "t";
|
|
58
57
|
export declare const TREATMENTS = "ts";
|
|
59
58
|
export declare const TREATMENT_WITH_CONFIG = "tc";
|