@splitsoftware/splitio-commons 2.2.1-rc.2 → 2.2.1-rc.3
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/sdkFactory/index.js +3 -0
- package/cjs/storages/inRedis/index.js +3 -1
- package/esm/sdkFactory/index.js +4 -1
- package/esm/storages/inRedis/index.js +3 -1
- package/package.json +1 -1
- package/src/sdkFactory/index.ts +4 -1
- package/src/storages/inRedis/index.ts +4 -1
- package/src/storages/types.ts +1 -0
package/cjs/sdkFactory/index.js
CHANGED
|
@@ -45,6 +45,9 @@ function sdkFactory(params) {
|
|
|
45
45
|
readiness.splits.emit(constants_2.SDK_SPLITS_ARRIVED);
|
|
46
46
|
readiness.segments.emit(constants_2.SDK_SEGMENTS_ARRIVED);
|
|
47
47
|
},
|
|
48
|
+
onReadyFromCacheCb: function () {
|
|
49
|
+
readiness.splits.emit(constants_2.SDK_SPLITS_CACHE_LOADED);
|
|
50
|
+
}
|
|
48
51
|
});
|
|
49
52
|
// @TODO add support for dataloader: `if (params.dataLoader) params.dataLoader(storage);`
|
|
50
53
|
var clients = {};
|
|
@@ -29,13 +29,15 @@ function InRedisStorage(options) {
|
|
|
29
29
|
function InRedisStorageFactory(params) {
|
|
30
30
|
if (!RD)
|
|
31
31
|
throw new Error('The SDK Redis storage is not available. Your runtime environment must support CommonJS (`require`) to import the ioredis dependency.');
|
|
32
|
-
var onReadyCb = params.onReadyCb, settings = params.settings, log = params.settings.log;
|
|
32
|
+
var onReadyFromCacheCb = params.onReadyFromCacheCb, onReadyCb = params.onReadyCb, settings = params.settings, log = params.settings.log;
|
|
33
33
|
var metadata = (0, utils_1.metadataBuilder)(settings);
|
|
34
34
|
var keys = new KeyBuilderSS_1.KeyBuilderSS(prefix, metadata);
|
|
35
35
|
var redisClient = new RD(log, options.options || {});
|
|
36
36
|
var telemetry = new TelemetryCacheInRedis_1.TelemetryCacheInRedis(log, keys, redisClient);
|
|
37
37
|
var impressionCountsCache = new ImpressionCountsCacheInRedis_1.ImpressionCountsCacheInRedis(log, keys.buildImpressionsCountKey(), redisClient);
|
|
38
38
|
var uniqueKeysCache = new UniqueKeysCacheInRedis_1.UniqueKeysCacheInRedis(log, keys.buildUniqueKeysKey(), redisClient);
|
|
39
|
+
// RedisAdapter queues operations before connection
|
|
40
|
+
onReadyFromCacheCb();
|
|
39
41
|
// subscription to Redis connect event in order to emit SDK_READY event on consumer mode
|
|
40
42
|
redisClient.on('connect', function () {
|
|
41
43
|
onReadyCb();
|
package/esm/sdkFactory/index.js
CHANGED
|
@@ -5,7 +5,7 @@ import { telemetryTrackerFactory } from '../trackers/telemetryTracker';
|
|
|
5
5
|
import { validateAndTrackApiKey } from '../utils/inputValidation/apiKey';
|
|
6
6
|
import { createLoggerAPI } from '../logger/sdkLogger';
|
|
7
7
|
import { NEW_FACTORY, RETRIEVE_MANAGER } from '../logger/constants';
|
|
8
|
-
import { SDK_SPLITS_ARRIVED, SDK_SEGMENTS_ARRIVED } from '../readiness/constants';
|
|
8
|
+
import { SDK_SPLITS_ARRIVED, SDK_SEGMENTS_ARRIVED, SDK_SPLITS_CACHE_LOADED } from '../readiness/constants';
|
|
9
9
|
import { objectAssign } from '../utils/lang/objectAssign';
|
|
10
10
|
import { strategyDebugFactory } from '../trackers/strategy/strategyDebug';
|
|
11
11
|
import { strategyOptimizedFactory } from '../trackers/strategy/strategyOptimized';
|
|
@@ -42,6 +42,9 @@ export function sdkFactory(params) {
|
|
|
42
42
|
readiness.splits.emit(SDK_SPLITS_ARRIVED);
|
|
43
43
|
readiness.segments.emit(SDK_SEGMENTS_ARRIVED);
|
|
44
44
|
},
|
|
45
|
+
onReadyFromCacheCb: function () {
|
|
46
|
+
readiness.splits.emit(SDK_SPLITS_CACHE_LOADED);
|
|
47
|
+
}
|
|
45
48
|
});
|
|
46
49
|
// @TODO add support for dataloader: `if (params.dataLoader) params.dataLoader(storage);`
|
|
47
50
|
var clients = {};
|
|
@@ -26,13 +26,15 @@ export function InRedisStorage(options) {
|
|
|
26
26
|
function InRedisStorageFactory(params) {
|
|
27
27
|
if (!RD)
|
|
28
28
|
throw new Error('The SDK Redis storage is not available. Your runtime environment must support CommonJS (`require`) to import the ioredis dependency.');
|
|
29
|
-
var onReadyCb = params.onReadyCb, settings = params.settings, log = params.settings.log;
|
|
29
|
+
var onReadyFromCacheCb = params.onReadyFromCacheCb, onReadyCb = params.onReadyCb, settings = params.settings, log = params.settings.log;
|
|
30
30
|
var metadata = metadataBuilder(settings);
|
|
31
31
|
var keys = new KeyBuilderSS(prefix, metadata);
|
|
32
32
|
var redisClient = new RD(log, options.options || {});
|
|
33
33
|
var telemetry = new TelemetryCacheInRedis(log, keys, redisClient);
|
|
34
34
|
var impressionCountsCache = new ImpressionCountsCacheInRedis(log, keys.buildImpressionsCountKey(), redisClient);
|
|
35
35
|
var uniqueKeysCache = new UniqueKeysCacheInRedis(log, keys.buildUniqueKeysKey(), redisClient);
|
|
36
|
+
// RedisAdapter queues operations before connection
|
|
37
|
+
onReadyFromCacheCb();
|
|
36
38
|
// subscription to Redis connect event in order to emit SDK_READY event on consumer mode
|
|
37
39
|
redisClient.on('connect', function () {
|
|
38
40
|
onReadyCb();
|
package/package.json
CHANGED
package/src/sdkFactory/index.ts
CHANGED
|
@@ -7,7 +7,7 @@ import SplitIO from '../../types/splitio';
|
|
|
7
7
|
import { validateAndTrackApiKey } from '../utils/inputValidation/apiKey';
|
|
8
8
|
import { createLoggerAPI } from '../logger/sdkLogger';
|
|
9
9
|
import { NEW_FACTORY, RETRIEVE_MANAGER } from '../logger/constants';
|
|
10
|
-
import { SDK_SPLITS_ARRIVED, SDK_SEGMENTS_ARRIVED } from '../readiness/constants';
|
|
10
|
+
import { SDK_SPLITS_ARRIVED, SDK_SEGMENTS_ARRIVED, SDK_SPLITS_CACHE_LOADED } from '../readiness/constants';
|
|
11
11
|
import { objectAssign } from '../utils/lang/objectAssign';
|
|
12
12
|
import { strategyDebugFactory } from '../trackers/strategy/strategyDebug';
|
|
13
13
|
import { strategyOptimizedFactory } from '../trackers/strategy/strategyOptimized';
|
|
@@ -52,6 +52,9 @@ export function sdkFactory(params: ISdkFactoryParams): SplitIO.ISDK | SplitIO.IA
|
|
|
52
52
|
readiness.splits.emit(SDK_SPLITS_ARRIVED);
|
|
53
53
|
readiness.segments.emit(SDK_SEGMENTS_ARRIVED);
|
|
54
54
|
},
|
|
55
|
+
onReadyFromCacheCb: () => {
|
|
56
|
+
readiness.splits.emit(SDK_SPLITS_CACHE_LOADED);
|
|
57
|
+
}
|
|
55
58
|
});
|
|
56
59
|
// @TODO add support for dataloader: `if (params.dataLoader) params.dataLoader(storage);`
|
|
57
60
|
const clients: Record<string, SplitIO.IBasicClient> = {};
|
|
@@ -36,7 +36,7 @@ export function InRedisStorage(options: InRedisStorageOptions = {}): IStorageAsy
|
|
|
36
36
|
function InRedisStorageFactory(params: IStorageFactoryParams): IStorageAsync {
|
|
37
37
|
if (!RD) throw new Error('The SDK Redis storage is not available. Your runtime environment must support CommonJS (`require`) to import the ioredis dependency.');
|
|
38
38
|
|
|
39
|
-
const { onReadyCb, settings, settings: { log } } = params;
|
|
39
|
+
const { onReadyFromCacheCb, onReadyCb, settings, settings: { log } } = params;
|
|
40
40
|
const metadata = metadataBuilder(settings);
|
|
41
41
|
const keys = new KeyBuilderSS(prefix, metadata);
|
|
42
42
|
const redisClient = new RD(log, options.options || {});
|
|
@@ -44,6 +44,9 @@ export function InRedisStorage(options: InRedisStorageOptions = {}): IStorageAsy
|
|
|
44
44
|
const impressionCountsCache = new ImpressionCountsCacheInRedis(log, keys.buildImpressionsCountKey(), redisClient);
|
|
45
45
|
const uniqueKeysCache = new UniqueKeysCacheInRedis(log, keys.buildUniqueKeysKey(), redisClient);
|
|
46
46
|
|
|
47
|
+
// RedisAdapter queues operations before connection
|
|
48
|
+
onReadyFromCacheCb();
|
|
49
|
+
|
|
47
50
|
// subscription to Redis connect event in order to emit SDK_READY event on consumer mode
|
|
48
51
|
redisClient.on('connect', () => {
|
|
49
52
|
onReadyCb();
|
package/src/storages/types.ts
CHANGED
|
@@ -472,6 +472,7 @@ export interface IStorageFactoryParams {
|
|
|
472
472
|
* It is meant for emitting SDK_READY event in consumer mode, and waiting before using the storage in the synchronizer.
|
|
473
473
|
*/
|
|
474
474
|
onReadyCb: (error?: any) => void,
|
|
475
|
+
onReadyFromCacheCb: () => void,
|
|
475
476
|
}
|
|
476
477
|
|
|
477
478
|
|