@splitsoftware/splitio-commons 1.12.1-rc.2 → 1.12.1-rc.4
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 +10 -9
- package/cjs/sdkClient/client.js +16 -13
- package/cjs/sdkClient/clientInputValidation.js +15 -15
- package/cjs/sdkFactory/index.js +1 -1
- package/cjs/sdkManager/index.js +14 -13
- package/cjs/storages/inRedis/ImpressionCountsCacheInRedis.js +5 -1
- package/cjs/storages/inRedis/RedisAdapter.js +29 -12
- package/cjs/storages/inRedis/SegmentsCacheInRedis.js +2 -2
- package/cjs/storages/inRedis/SplitsCacheInRedis.js +5 -9
- package/cjs/utils/constants/index.js +16 -2
- package/cjs/utils/redis/RedisMock.js +7 -1
- package/esm/sdkClient/client.js +17 -14
- package/esm/sdkClient/clientInputValidation.js +16 -16
- package/esm/sdkFactory/index.js +1 -1
- package/esm/sdkManager/index.js +8 -7
- package/esm/storages/inRedis/ImpressionCountsCacheInRedis.js +5 -1
- package/esm/storages/inRedis/RedisAdapter.js +29 -12
- package/esm/storages/inRedis/SegmentsCacheInRedis.js +2 -2
- package/esm/storages/inRedis/SplitsCacheInRedis.js +5 -9
- package/esm/utils/constants/index.js +14 -0
- package/esm/utils/redis/RedisMock.js +7 -1
- package/package.json +1 -1
- package/src/sdkClient/client.ts +15 -15
- package/src/sdkClient/clientInputValidation.ts +16 -16
- package/src/sdkFactory/index.ts +1 -1
- package/src/sdkFactory/types.ts +3 -7
- package/src/sdkManager/index.ts +11 -11
- package/src/storages/inRedis/ImpressionCountsCacheInRedis.ts +5 -1
- package/src/storages/inRedis/RedisAdapter.ts +35 -17
- package/src/storages/inRedis/SegmentsCacheInRedis.ts +2 -2
- package/src/storages/inRedis/SplitsCacheInRedis.ts +5 -9
- package/src/trackers/impressionObserver/utils.ts +1 -1
- package/src/utils/constants/index.ts +16 -0
- package/src/utils/redis/RedisMock.ts +9 -1
- package/types/sdkFactory/types.d.ts +3 -3
- package/types/sdkManager/index.d.ts +2 -3
- package/types/storages/inRedis/RedisAdapter.d.ts +1 -2
- package/types/storages/inRedis/SegmentsCacheInRedis.d.ts +1 -1
- package/types/storages/inRedis/SplitsCacheInRedis.d.ts +2 -7
- package/types/trackers/impressionObserver/utils.d.ts +1 -1
- package/types/utils/constants/index.d.ts +12 -0
- package/types/utils/redis/RedisMock.d.ts +1 -0
package/src/sdkManager/index.ts
CHANGED
|
@@ -5,12 +5,9 @@ import { validateSplit, validateSplitExistence, validateIfNotDestroyed, validate
|
|
|
5
5
|
import { ISplitsCacheAsync, ISplitsCacheSync } from '../storages/types';
|
|
6
6
|
import { ISdkReadinessManager } from '../readiness/types';
|
|
7
7
|
import { ISplit } from '../dtos/types';
|
|
8
|
-
import { SplitIO } from '../types';
|
|
9
|
-
import {
|
|
10
|
-
|
|
11
|
-
const SPLIT_FN_LABEL = 'split';
|
|
12
|
-
const SPLITS_FN_LABEL = 'splits';
|
|
13
|
-
const NAMES_FN_LABEL = 'names';
|
|
8
|
+
import { ISettings, SplitIO } from '../types';
|
|
9
|
+
import { isStorageSync } from '../trackers/impressionObserver/utils';
|
|
10
|
+
import { SPLIT_FN_LABEL, SPLITS_FN_LABEL, NAMES_FN_LABEL } from '../utils/constants';
|
|
14
11
|
|
|
15
12
|
function collectTreatments(splitObject: ISplit) {
|
|
16
13
|
const conditions = splitObject.conditions;
|
|
@@ -49,11 +46,14 @@ function objectsToViews(splitObjects: ISplit[]) {
|
|
|
49
46
|
}
|
|
50
47
|
|
|
51
48
|
export function sdkManagerFactory<TSplitCache extends ISplitsCacheSync | ISplitsCacheAsync>(
|
|
52
|
-
|
|
49
|
+
settings: Pick<ISettings, 'log' | 'mode'>,
|
|
53
50
|
splits: TSplitCache,
|
|
54
|
-
{ readinessManager, sdkStatus }: ISdkReadinessManager
|
|
51
|
+
{ readinessManager, sdkStatus }: ISdkReadinessManager,
|
|
55
52
|
): TSplitCache extends ISplitsCacheAsync ? SplitIO.IAsyncManager : SplitIO.IManager {
|
|
56
53
|
|
|
54
|
+
const log = settings.log;
|
|
55
|
+
const isSync = isStorageSync(settings);
|
|
56
|
+
|
|
57
57
|
return objectAssign(
|
|
58
58
|
// Proto-linkage of the readiness Event Emitter
|
|
59
59
|
Object.create(sdkStatus),
|
|
@@ -64,7 +64,7 @@ export function sdkManagerFactory<TSplitCache extends ISplitsCacheSync | ISplits
|
|
|
64
64
|
split(featureFlagName: string) {
|
|
65
65
|
const splitName = validateSplit(log, featureFlagName, SPLIT_FN_LABEL);
|
|
66
66
|
if (!validateIfNotDestroyed(log, readinessManager, SPLIT_FN_LABEL) || !validateIfOperational(log, readinessManager, SPLIT_FN_LABEL) || !splitName) {
|
|
67
|
-
return null;
|
|
67
|
+
return isSync ? null : Promise.resolve(null);
|
|
68
68
|
}
|
|
69
69
|
|
|
70
70
|
const split = splits.getSplit(splitName);
|
|
@@ -85,7 +85,7 @@ export function sdkManagerFactory<TSplitCache extends ISplitsCacheSync | ISplits
|
|
|
85
85
|
*/
|
|
86
86
|
splits() {
|
|
87
87
|
if (!validateIfNotDestroyed(log, readinessManager, SPLITS_FN_LABEL) || !validateIfOperational(log, readinessManager, SPLITS_FN_LABEL)) {
|
|
88
|
-
return [];
|
|
88
|
+
return isSync ? [] : Promise.resolve([]);
|
|
89
89
|
}
|
|
90
90
|
const currentSplits = splits.getAll();
|
|
91
91
|
|
|
@@ -98,7 +98,7 @@ export function sdkManagerFactory<TSplitCache extends ISplitsCacheSync | ISplits
|
|
|
98
98
|
*/
|
|
99
99
|
names() {
|
|
100
100
|
if (!validateIfNotDestroyed(log, readinessManager, NAMES_FN_LABEL) || !validateIfOperational(log, readinessManager, NAMES_FN_LABEL)) {
|
|
101
|
-
return [];
|
|
101
|
+
return isSync ? [] : Promise.resolve([]);
|
|
102
102
|
}
|
|
103
103
|
const splitNames = splits.getSplitNames();
|
|
104
104
|
|
|
@@ -27,7 +27,11 @@ export class ImpressionCountsCacheInRedis extends ImpressionCountsCacheInMemory
|
|
|
27
27
|
const keys = Object.keys(counts);
|
|
28
28
|
if (!keys.length) return Promise.resolve(false);
|
|
29
29
|
|
|
30
|
-
|
|
30
|
+
const pipeline = this.redis.pipeline();
|
|
31
|
+
keys.forEach(key => {
|
|
32
|
+
pipeline.hincrby(this.key, key, counts[key]);
|
|
33
|
+
});
|
|
34
|
+
return pipeline.exec()
|
|
31
35
|
.then(data => {
|
|
32
36
|
// If this is the creation of the key on Redis, set the expiration for it in 3600 seconds.
|
|
33
37
|
if (data.length && data.length === keys.length) {
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import ioredis from 'ioredis';
|
|
1
|
+
import ioredis, { Pipeline } from 'ioredis';
|
|
2
2
|
import { ILogger } from '../../logger/types';
|
|
3
3
|
import { merge, isString } from '../../utils/lang';
|
|
4
4
|
import { _Set, setToArray, ISet } from '../../utils/lang/sets';
|
|
@@ -8,7 +8,8 @@ import { timeout } from '../../utils/promise/timeout';
|
|
|
8
8
|
const LOG_PREFIX = 'storage:redis-adapter: ';
|
|
9
9
|
|
|
10
10
|
// If we ever decide to fully wrap every method, there's a Commander.getBuiltinCommands from ioredis.
|
|
11
|
-
const METHODS_TO_PROMISE_WRAP = ['set', 'exec', 'del', 'get', 'keys', 'sadd', 'srem', 'sismember', 'smembers', 'incr', 'rpush', 'expire', 'mget', 'lrange', 'ltrim', 'hset', 'hincrby', 'popNRaw'
|
|
11
|
+
const METHODS_TO_PROMISE_WRAP = ['set', 'exec', 'del', 'get', 'keys', 'sadd', 'srem', 'sismember', 'smembers', 'incr', 'rpush', 'expire', 'mget', 'lrange', 'ltrim', 'hset', 'hincrby', 'popNRaw'];
|
|
12
|
+
const METHODS_TO_PROMISE_WRAP_EXEC = ['pipeline'];
|
|
12
13
|
|
|
13
14
|
// Not part of the settings since it'll vary on each storage. We should be removing storage specific logic from elsewhere.
|
|
14
15
|
const DEFAULT_OPTIONS = {
|
|
@@ -38,7 +39,7 @@ export class RedisAdapter extends ioredis {
|
|
|
38
39
|
private _notReadyCommandsQueue?: IRedisCommand[];
|
|
39
40
|
private _runningCommands: ISet<Promise<any>>;
|
|
40
41
|
|
|
41
|
-
constructor(log: ILogger, storageSettings
|
|
42
|
+
constructor(log: ILogger, storageSettings: Record<string, any> = {}) {
|
|
42
43
|
const options = RedisAdapter._defineOptions(storageSettings);
|
|
43
44
|
// Call the ioredis constructor
|
|
44
45
|
super(...RedisAdapter._defineLibrarySettings(options));
|
|
@@ -52,10 +53,6 @@ export class RedisAdapter extends ioredis {
|
|
|
52
53
|
this._setDisconnectWrapper();
|
|
53
54
|
}
|
|
54
55
|
|
|
55
|
-
pipelineExec(commands?: (string | number)[][]): Promise<Array<[Error | null, any]>> {
|
|
56
|
-
return this.pipeline(commands as string[][]).exec();
|
|
57
|
-
}
|
|
58
|
-
|
|
59
56
|
_listenToEvents() {
|
|
60
57
|
this.once('ready', () => {
|
|
61
58
|
const commandsCount = this._notReadyCommandsQueue ? this._notReadyCommandsQueue.length : 0;
|
|
@@ -76,21 +73,22 @@ export class RedisAdapter extends ioredis {
|
|
|
76
73
|
_setTimeoutWrappers() {
|
|
77
74
|
const instance: Record<string, any> = this;
|
|
78
75
|
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
76
|
+
const wrapCommand = (originalMethod: Function, methodName: string) => {
|
|
77
|
+
// The value of "this" in this function should be the instance actually executing the method. It might be the instance referred (the base one)
|
|
78
|
+
// or it can be the instance of a Pipeline object.
|
|
79
|
+
return function (this: RedisAdapter | Pipeline) {
|
|
83
80
|
const params = arguments;
|
|
81
|
+
const caller = this;
|
|
84
82
|
|
|
85
83
|
function commandWrapper() {
|
|
86
84
|
instance.log.debug(`${LOG_PREFIX}Executing ${methodName}.`);
|
|
87
|
-
const result = originalMethod.apply(
|
|
85
|
+
const result = originalMethod.apply(caller, params);
|
|
88
86
|
|
|
89
87
|
if (thenable(result)) {
|
|
90
88
|
// For handling pending commands on disconnect, add to the set and remove once finished.
|
|
91
89
|
// On sync commands there's no need, only thenables.
|
|
92
90
|
instance._runningCommands.add(result);
|
|
93
|
-
const cleanUpRunningCommandsCb = ()
|
|
91
|
+
const cleanUpRunningCommandsCb = function () {
|
|
94
92
|
instance._runningCommands.delete(result);
|
|
95
93
|
};
|
|
96
94
|
// Both success and error remove from queue.
|
|
@@ -107,10 +105,10 @@ export class RedisAdapter extends ioredis {
|
|
|
107
105
|
}
|
|
108
106
|
|
|
109
107
|
if (instance._notReadyCommandsQueue) {
|
|
110
|
-
return new Promise((
|
|
108
|
+
return new Promise((resolve, reject) => {
|
|
111
109
|
instance._notReadyCommandsQueue.unshift({
|
|
112
|
-
resolve
|
|
113
|
-
reject
|
|
110
|
+
resolve,
|
|
111
|
+
reject,
|
|
114
112
|
command: commandWrapper,
|
|
115
113
|
name: methodName.toUpperCase()
|
|
116
114
|
});
|
|
@@ -119,6 +117,26 @@ export class RedisAdapter extends ioredis {
|
|
|
119
117
|
return commandWrapper();
|
|
120
118
|
}
|
|
121
119
|
};
|
|
120
|
+
};
|
|
121
|
+
|
|
122
|
+
// Wrap regular async methods to track timeouts and queue when Redis is not yet executing commands.
|
|
123
|
+
METHODS_TO_PROMISE_WRAP.forEach(methodName => {
|
|
124
|
+
const originalFn = instance[methodName];
|
|
125
|
+
instance[methodName] = wrapCommand(originalFn, methodName);
|
|
126
|
+
});
|
|
127
|
+
|
|
128
|
+
// Special handling for pipeline~like methods. We need to wrap the async trigger, which is exec, but return the Pipeline right away.
|
|
129
|
+
METHODS_TO_PROMISE_WRAP_EXEC.forEach(methodName => {
|
|
130
|
+
const originalFn = instance[methodName];
|
|
131
|
+
// "First level wrapper" to handle the sync execution and wrap async, queueing later if applicable.
|
|
132
|
+
instance[methodName] = function () {
|
|
133
|
+
const res = originalFn.apply(instance, arguments);
|
|
134
|
+
const originalExec = res.exec;
|
|
135
|
+
|
|
136
|
+
res.exec = wrapCommand(originalExec, methodName + '.exec').bind(res);
|
|
137
|
+
|
|
138
|
+
return res;
|
|
139
|
+
};
|
|
122
140
|
});
|
|
123
141
|
}
|
|
124
142
|
|
|
@@ -181,7 +199,7 @@ export class RedisAdapter extends ioredis {
|
|
|
181
199
|
/**
|
|
182
200
|
* Parses the options into what we care about.
|
|
183
201
|
*/
|
|
184
|
-
static _defineOptions({ connectionTimeout, operationTimeout, url, host, port, db, pass, tls }: Record<string, any>
|
|
202
|
+
static _defineOptions({ connectionTimeout, operationTimeout, url, host, port, db, pass, tls }: Record<string, any>) {
|
|
185
203
|
const parsedOptions = {
|
|
186
204
|
connectionTimeout, operationTimeout, url, host, port, db, pass, tls
|
|
187
205
|
};
|
|
@@ -72,8 +72,8 @@ export class SegmentsCacheInRedis implements ISegmentsCacheAsync {
|
|
|
72
72
|
return this.redis.smembers(this.keys.buildRegisteredSegmentsKey());
|
|
73
73
|
}
|
|
74
74
|
|
|
75
|
-
// @TODO remove
|
|
75
|
+
// @TODO remove or implement. It is not being used.
|
|
76
76
|
clear() {
|
|
77
|
-
return
|
|
77
|
+
return Promise.resolve();
|
|
78
78
|
}
|
|
79
79
|
}
|
|
@@ -192,7 +192,7 @@ export class SplitsCacheInRedis extends AbstractSplitsCacheAsync {
|
|
|
192
192
|
*/
|
|
193
193
|
getAll(): Promise<ISplit[]> {
|
|
194
194
|
return this.redis.keys(this.keys.searchPatternForSplitKeys())
|
|
195
|
-
.then((listOfKeys) => this.redis.
|
|
195
|
+
.then((listOfKeys) => this.redis.pipeline(listOfKeys.map(k => ['get', k])).exec())
|
|
196
196
|
.then(processPipelineAnswer)
|
|
197
197
|
.then((splitDefinitions) => splitDefinitions.map((splitDefinition) => {
|
|
198
198
|
return JSON.parse(splitDefinition);
|
|
@@ -213,10 +213,10 @@ export class SplitsCacheInRedis extends AbstractSplitsCacheAsync {
|
|
|
213
213
|
/**
|
|
214
214
|
* Get list of feature flag names related to a given list of flag set names.
|
|
215
215
|
* The returned promise is resolved with the list of feature flag names per flag set,
|
|
216
|
-
* or rejected if the pipelined redis operation fails.
|
|
216
|
+
* or rejected if the pipelined redis operation fails (e.g., timeout).
|
|
217
217
|
*/
|
|
218
218
|
getNamesByFlagSets(flagSets: string[]): Promise<ISet<string>[]> {
|
|
219
|
-
return this.redis.
|
|
219
|
+
return this.redis.pipeline(flagSets.map(flagSet => ['smembers', this.keys.buildFlagSetKey(flagSet)])).exec()
|
|
220
220
|
.then((results) => results.map(([e, value], index) => {
|
|
221
221
|
if (e === null) return value;
|
|
222
222
|
|
|
@@ -252,13 +252,9 @@ export class SplitsCacheInRedis extends AbstractSplitsCacheAsync {
|
|
|
252
252
|
});
|
|
253
253
|
}
|
|
254
254
|
|
|
255
|
-
|
|
256
|
-
* Delete everything in the current database.
|
|
257
|
-
*
|
|
258
|
-
* @NOTE documentation says it never fails.
|
|
259
|
-
*/
|
|
255
|
+
// @TODO remove or implement. It is not being used.
|
|
260
256
|
clear() {
|
|
261
|
-
return
|
|
257
|
+
return Promise.resolve();
|
|
262
258
|
}
|
|
263
259
|
|
|
264
260
|
/**
|
|
@@ -4,6 +4,6 @@ import { ISettings } from '../../types';
|
|
|
4
4
|
/**
|
|
5
5
|
* Storage is async if mode is consumer or partial consumer
|
|
6
6
|
*/
|
|
7
|
-
export function isStorageSync(settings: ISettings) {
|
|
7
|
+
export function isStorageSync(settings: Pick<ISettings, 'mode'>) {
|
|
8
8
|
return [CONSUMER_MODE, CONSUMER_PARTIAL_MODE].indexOf(settings.mode) === -1 ? true : false;
|
|
9
9
|
}
|
|
@@ -39,6 +39,22 @@ export const CONSENT_GRANTED = 'GRANTED'; // The user has granted consent for tr
|
|
|
39
39
|
export const CONSENT_DECLINED = 'DECLINED'; // The user has declined consent for tracking events and impressions
|
|
40
40
|
export const CONSENT_UNKNOWN = 'UNKNOWN'; // The user has neither granted nor declined consent for tracking events and impressions
|
|
41
41
|
|
|
42
|
+
// Client method names
|
|
43
|
+
export const GET_TREATMENT = 'getTreatment';
|
|
44
|
+
export const GET_TREATMENTS = 'getTreatments';
|
|
45
|
+
export const GET_TREATMENT_WITH_CONFIG = 'getTreatmentWithConfig';
|
|
46
|
+
export const GET_TREATMENTS_WITH_CONFIG = 'getTreatmentsWithConfig';
|
|
47
|
+
export const GET_TREATMENTS_BY_FLAG_SET = 'getTreatmentsByFlagSet';
|
|
48
|
+
export const GET_TREATMENTS_BY_FLAG_SETS = 'getTreatmentsByFlagSets';
|
|
49
|
+
export const GET_TREATMENTS_WITH_CONFIG_BY_FLAG_SET = 'getTreatmentsWithConfigByFlagSet';
|
|
50
|
+
export const GET_TREATMENTS_WITH_CONFIG_BY_FLAG_SETS = 'getTreatmentsWithConfigByFlagSets';
|
|
51
|
+
export const TRACK_FN_LABEL = 'track';
|
|
52
|
+
|
|
53
|
+
// Manager method names
|
|
54
|
+
export const SPLIT_FN_LABEL = 'split';
|
|
55
|
+
export const SPLITS_FN_LABEL = 'splits';
|
|
56
|
+
export const NAMES_FN_LABEL = 'names';
|
|
57
|
+
|
|
42
58
|
// Telemetry
|
|
43
59
|
export const QUEUED = 0;
|
|
44
60
|
export const DROPPED = 1;
|
|
@@ -8,10 +8,13 @@ function asyncFunction(data: any): Promise<any> {
|
|
|
8
8
|
}
|
|
9
9
|
|
|
10
10
|
const IDENTITY_METHODS: string[] = [];
|
|
11
|
-
const ASYNC_METHODS = ['rpush', 'hincrby'
|
|
11
|
+
const ASYNC_METHODS = ['rpush', 'hincrby'];
|
|
12
|
+
const PIPELINE_METHODS = ['rpush', 'hincrby'];
|
|
12
13
|
|
|
13
14
|
export class RedisMock {
|
|
14
15
|
|
|
16
|
+
private pipelineMethods: any = { exec: jest.fn(asyncFunction) };
|
|
17
|
+
|
|
15
18
|
constructor() {
|
|
16
19
|
IDENTITY_METHODS.forEach(method => {
|
|
17
20
|
this[method] = jest.fn(identityFunction);
|
|
@@ -19,5 +22,10 @@ export class RedisMock {
|
|
|
19
22
|
ASYNC_METHODS.forEach(method => {
|
|
20
23
|
this[method] = jest.fn(asyncFunction);
|
|
21
24
|
});
|
|
25
|
+
PIPELINE_METHODS.forEach(method => {
|
|
26
|
+
this.pipelineMethods[method] = this[method];
|
|
27
|
+
});
|
|
28
|
+
|
|
29
|
+
this.pipeline = jest.fn(() => { return this.pipelineMethods; });
|
|
22
30
|
}
|
|
23
31
|
}
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import { IIntegrationManager, IIntegrationFactoryParams } from '../integrations/types';
|
|
2
2
|
import { ISignalListener } from '../listeners/types';
|
|
3
|
-
import { ILogger } from '../logger/types';
|
|
4
3
|
import { IReadinessManager, ISdkReadinessManager } from '../readiness/types';
|
|
4
|
+
import type { sdkManagerFactory } from '../sdkManager';
|
|
5
5
|
import { IFetch, ISplitApi, IEventSourceConstructor } from '../services/types';
|
|
6
|
-
import { IStorageAsync, IStorageSync,
|
|
6
|
+
import { IStorageAsync, IStorageSync, IStorageFactoryParams } from '../storages/types';
|
|
7
7
|
import { ISyncManager } from '../sync/types';
|
|
8
8
|
import { IImpressionObserver } from '../trackers/impressionObserver/types';
|
|
9
9
|
import { IImpressionsTracker, IEventTracker, ITelemetryTracker, IFilterAdapter, IUniqueKeysTracker } from '../trackers/types';
|
|
@@ -66,7 +66,7 @@ export interface ISdkFactoryParams {
|
|
|
66
66
|
storageFactory: (params: IStorageFactoryParams) => IStorageSync | IStorageAsync;
|
|
67
67
|
splitApiFactory?: (settings: ISettings, platform: IPlatform, telemetryTracker: ITelemetryTracker) => ISplitApi;
|
|
68
68
|
syncManagerFactory?: (params: ISdkFactoryContextSync) => ISyncManager;
|
|
69
|
-
sdkManagerFactory:
|
|
69
|
+
sdkManagerFactory: typeof sdkManagerFactory;
|
|
70
70
|
sdkClientMethodFactory: (params: ISdkFactoryContext) => ({
|
|
71
71
|
(): SplitIO.ICsClient;
|
|
72
72
|
(key: SplitIO.SplitKey, trafficType?: string | undefined): SplitIO.ICsClient;
|
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import { ISplitsCacheAsync, ISplitsCacheSync } from '../storages/types';
|
|
2
2
|
import { ISdkReadinessManager } from '../readiness/types';
|
|
3
|
-
import { SplitIO } from '../types';
|
|
4
|
-
|
|
5
|
-
export declare function sdkManagerFactory<TSplitCache extends ISplitsCacheSync | ISplitsCacheAsync>(log: ILogger, splits: TSplitCache, { readinessManager, sdkStatus }: ISdkReadinessManager): TSplitCache extends ISplitsCacheAsync ? SplitIO.IAsyncManager : SplitIO.IManager;
|
|
3
|
+
import { ISettings, SplitIO } from '../types';
|
|
4
|
+
export declare function sdkManagerFactory<TSplitCache extends ISplitsCacheSync | ISplitsCacheAsync>(settings: Pick<ISettings, 'log' | 'mode'>, splits: TSplitCache, { readinessManager, sdkStatus }: ISdkReadinessManager): TSplitCache extends ISplitsCacheAsync ? SplitIO.IAsyncManager : SplitIO.IManager;
|
|
@@ -9,7 +9,6 @@ export declare class RedisAdapter extends ioredis {
|
|
|
9
9
|
private _notReadyCommandsQueue?;
|
|
10
10
|
private _runningCommands;
|
|
11
11
|
constructor(log: ILogger, storageSettings?: Record<string, any>);
|
|
12
|
-
pipelineExec(commands?: (string | number)[][]): Promise<Array<[Error | null, any]>>;
|
|
13
12
|
_listenToEvents(): void;
|
|
14
13
|
_setTimeoutWrappers(): void;
|
|
15
14
|
_setDisconnectWrapper(): void;
|
|
@@ -21,5 +20,5 @@ export declare class RedisAdapter extends ioredis {
|
|
|
21
20
|
/**
|
|
22
21
|
* Parses the options into what we care about.
|
|
23
22
|
*/
|
|
24
|
-
static _defineOptions({ connectionTimeout, operationTimeout, url, host, port, db, pass, tls }
|
|
23
|
+
static _defineOptions({ connectionTimeout, operationTimeout, url, host, port, db, pass, tls }: Record<string, any>): object;
|
|
25
24
|
}
|
|
@@ -14,5 +14,5 @@ export declare class SegmentsCacheInRedis implements ISegmentsCacheAsync {
|
|
|
14
14
|
getChangeNumber(name: string): Promise<number>;
|
|
15
15
|
registerSegments(segments: string[]): Promise<boolean>;
|
|
16
16
|
getRegisteredSegments(): Promise<string[]>;
|
|
17
|
-
clear(): Promise<
|
|
17
|
+
clear(): Promise<void>;
|
|
18
18
|
}
|
|
@@ -77,7 +77,7 @@ export declare class SplitsCacheInRedis extends AbstractSplitsCacheAsync {
|
|
|
77
77
|
/**
|
|
78
78
|
* Get list of feature flag names related to a given list of flag set names.
|
|
79
79
|
* The returned promise is resolved with the list of feature flag names per flag set,
|
|
80
|
-
* or rejected if the pipelined redis operation fails.
|
|
80
|
+
* or rejected if the pipelined redis operation fails (e.g., timeout).
|
|
81
81
|
*/
|
|
82
82
|
getNamesByFlagSets(flagSets: string[]): Promise<ISet<string>[]>;
|
|
83
83
|
/**
|
|
@@ -87,12 +87,7 @@ export declare class SplitsCacheInRedis extends AbstractSplitsCacheAsync {
|
|
|
87
87
|
* It will never be rejected.
|
|
88
88
|
*/
|
|
89
89
|
trafficTypeExists(trafficType: string): Promise<boolean>;
|
|
90
|
-
|
|
91
|
-
* Delete everything in the current database.
|
|
92
|
-
*
|
|
93
|
-
* @NOTE documentation says it never fails.
|
|
94
|
-
*/
|
|
95
|
-
clear(): Promise<boolean>;
|
|
90
|
+
clear(): Promise<void>;
|
|
96
91
|
/**
|
|
97
92
|
* Fetches multiple splits definitions.
|
|
98
93
|
* Returned promise is rejected if redis operation fails.
|
|
@@ -24,6 +24,18 @@ export declare const STORAGE_PLUGGABLE: StorageType;
|
|
|
24
24
|
export declare const CONSENT_GRANTED = "GRANTED";
|
|
25
25
|
export declare const CONSENT_DECLINED = "DECLINED";
|
|
26
26
|
export declare const CONSENT_UNKNOWN = "UNKNOWN";
|
|
27
|
+
export declare const GET_TREATMENT = "getTreatment";
|
|
28
|
+
export declare const GET_TREATMENTS = "getTreatments";
|
|
29
|
+
export declare const GET_TREATMENT_WITH_CONFIG = "getTreatmentWithConfig";
|
|
30
|
+
export declare const GET_TREATMENTS_WITH_CONFIG = "getTreatmentsWithConfig";
|
|
31
|
+
export declare const GET_TREATMENTS_BY_FLAG_SET = "getTreatmentsByFlagSet";
|
|
32
|
+
export declare const GET_TREATMENTS_BY_FLAG_SETS = "getTreatmentsByFlagSets";
|
|
33
|
+
export declare const GET_TREATMENTS_WITH_CONFIG_BY_FLAG_SET = "getTreatmentsWithConfigByFlagSet";
|
|
34
|
+
export declare const GET_TREATMENTS_WITH_CONFIG_BY_FLAG_SETS = "getTreatmentsWithConfigByFlagSets";
|
|
35
|
+
export declare const TRACK_FN_LABEL = "track";
|
|
36
|
+
export declare const SPLIT_FN_LABEL = "split";
|
|
37
|
+
export declare const SPLITS_FN_LABEL = "splits";
|
|
38
|
+
export declare const NAMES_FN_LABEL = "names";
|
|
27
39
|
export declare const QUEUED = 0;
|
|
28
40
|
export declare const DROPPED = 1;
|
|
29
41
|
export declare const DEDUPED = 2;
|