@splitsoftware/splitio 10.17.3-rc.2 → 10.17.3-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/es/factory/browser.js +41 -33
- package/es/factory/node.js +41 -36
- package/es/index.js +16 -1
- package/es/platform/EventEmitter.js +300 -326
- package/es/platform/browser.js +4 -4
- package/es/platform/getEventSource/browser.js +2 -2
- package/es/platform/getEventSource/node.js +13 -12
- package/es/platform/getFetch/browser.js +2 -2
- package/es/platform/getFetch/node.js +13 -13
- package/es/platform/node.js +5 -5
- package/es/platform/request/options/node.js +6 -21
- package/es/settings/browser.js +9 -9
- package/es/settings/defaults/browser.js +13 -13
- package/es/settings/defaults/node.js +22 -22
- package/es/settings/defaults/version.js +1 -1
- package/es/settings/integrations/browser.js +3 -3
- package/es/settings/node.js +9 -12
- package/es/settings/storage/browser.js +31 -59
- package/es/settings/storage/node.js +62 -91
- package/es/umd.js +3 -3
- package/lib/factory/browser.js +61 -70
- package/lib/factory/node.js +59 -69
- package/lib/index.js +16 -4
- package/lib/platform/EventEmitter.js +303 -330
- package/lib/platform/browser.js +10 -18
- package/lib/platform/getEventSource/browser.js +5 -6
- package/lib/platform/getEventSource/node.js +18 -19
- package/lib/platform/getFetch/browser.js +7 -10
- package/lib/platform/getFetch/node.js +17 -18
- package/lib/platform/node.js +13 -23
- package/lib/platform/request/options/node.js +12 -31
- package/lib/settings/browser.js +18 -26
- package/lib/settings/defaults/browser.js +15 -19
- package/lib/settings/defaults/node.js +24 -28
- package/lib/settings/defaults/version.js +2 -4
- package/lib/settings/integrations/browser.js +7 -12
- package/lib/settings/node.js +17 -29
- package/lib/settings/storage/browser.js +36 -68
- package/lib/settings/storage/node.js +66 -97
- package/lib/umd.js +3 -8
- package/package.json +23 -28
- package/src/factory/browser.js +10 -1
- package/src/factory/node.js +10 -1
- package/src/index.js +16 -0
- package/src/platform/request/options/node.js +0 -15
- package/src/settings/.DS_Store +0 -0
- package/src/settings/browser.js +2 -0
- package/src/settings/defaults/version.js +1 -1
- package/src/settings/integrations/browser.js +2 -2
- package/src/settings/node.js +2 -3
- package/src/settings/storage/browser.js +0 -16
- package/src/settings/storage/node.js +0 -15
- package/es/settings/integrations/node.js +0 -5
- package/es/settings/runtime/node.js +0 -35
- package/lib/settings/integrations/node.js +0 -12
- package/lib/settings/runtime/node.js +0 -45
- package/src/settings/integrations/node.js +0 -5
- package/src/settings/runtime/node.js +0 -37
package/es/platform/browser.js
CHANGED
|
@@ -3,8 +3,8 @@ import { getFetch } from '../platform/getFetch/browser';
|
|
|
3
3
|
import { getEventSource } from '../platform/getEventSource/browser';
|
|
4
4
|
import { BrowserSignalListener } from '@splitsoftware/splitio-commons/esm/listeners/browser';
|
|
5
5
|
export var platform = {
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
6
|
+
getFetch: getFetch,
|
|
7
|
+
getEventSource: getEventSource,
|
|
8
|
+
EventEmitter: EventEmitter
|
|
9
9
|
};
|
|
10
|
-
export var SignalListener = BrowserSignalListener;
|
|
10
|
+
export var SignalListener = BrowserSignalListener;
|
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
export function getEventSource() {
|
|
2
|
-
|
|
3
|
-
}
|
|
2
|
+
return typeof EventSource === 'function' ? EventSource : undefined;
|
|
3
|
+
}
|
|
@@ -1,18 +1,19 @@
|
|
|
1
1
|
var __isCustom = false;
|
|
2
|
-
var __eventSource = undefined;
|
|
3
|
-
|
|
2
|
+
var __eventSource = undefined;
|
|
3
|
+
// This function is only exposed for testing purposes.
|
|
4
4
|
export function __setEventSource(eventSource) {
|
|
5
|
-
|
|
6
|
-
|
|
5
|
+
__eventSource = eventSource;
|
|
6
|
+
__isCustom = true;
|
|
7
7
|
}
|
|
8
8
|
export function __restore() {
|
|
9
|
-
|
|
9
|
+
__isCustom = false;
|
|
10
10
|
}
|
|
11
11
|
export function getEventSource() {
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
}
|
|
12
|
+
// returns EventSource at `eventsource` package. If not available, return global EventSource or undefined
|
|
13
|
+
try {
|
|
14
|
+
return __isCustom ? __eventSource : require('eventsource');
|
|
15
|
+
}
|
|
16
|
+
catch (error) {
|
|
17
|
+
return typeof EventSource === 'function' ? EventSource : undefined;
|
|
18
|
+
}
|
|
19
|
+
}
|
|
@@ -1,18 +1,18 @@
|
|
|
1
1
|
var nodeFetch;
|
|
2
|
-
|
|
3
2
|
try {
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
3
|
+
nodeFetch = require('node-fetch');
|
|
4
|
+
// Handle node-fetch issue https://github.com/node-fetch/node-fetch/issues/1037
|
|
5
|
+
if (typeof nodeFetch !== 'function')
|
|
6
|
+
nodeFetch = nodeFetch.default;
|
|
7
|
+
}
|
|
8
|
+
catch (error) {
|
|
9
|
+
// Try to access global fetch if `node-fetch` package couldn't be imported (e.g., not in a Node environment)
|
|
10
|
+
nodeFetch = typeof fetch === 'function' ? fetch : undefined;
|
|
11
|
+
}
|
|
12
|
+
// This function is only exposed for testing purposes.
|
|
13
13
|
export function __setFetch(fetch) {
|
|
14
|
-
|
|
14
|
+
nodeFetch = fetch;
|
|
15
15
|
}
|
|
16
16
|
export function getFetch() {
|
|
17
|
-
|
|
18
|
-
}
|
|
17
|
+
return nodeFetch;
|
|
18
|
+
}
|
package/es/platform/node.js
CHANGED
|
@@ -4,9 +4,9 @@ import { getEventSource } from '../platform/getEventSource/node';
|
|
|
4
4
|
import { getOptions } from '../platform/request/options/node';
|
|
5
5
|
import { NodeSignalListener } from '@splitsoftware/splitio-commons/esm/listeners/node';
|
|
6
6
|
export var platform = {
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
7
|
+
getOptions: getOptions,
|
|
8
|
+
getFetch: getFetch,
|
|
9
|
+
getEventSource: getEventSource,
|
|
10
|
+
EventEmitter: EventEmitter
|
|
11
11
|
};
|
|
12
|
-
export var SignalListener = NodeSignalListener;
|
|
12
|
+
export var SignalListener = NodeSignalListener;
|
|
@@ -1,28 +1,13 @@
|
|
|
1
|
-
/**
|
|
2
|
-
Copyright 2022 Split Software
|
|
3
|
-
|
|
4
|
-
Licensed under the Apache License, Version 2.0 (the "License");
|
|
5
|
-
you may not use this file except in compliance with the License.
|
|
6
|
-
You may obtain a copy of the License at
|
|
7
|
-
|
|
8
|
-
http://www.apache.org/licenses/LICENSE-2.0
|
|
9
|
-
|
|
10
|
-
Unless required by applicable law or agreed to in writing, software
|
|
11
|
-
distributed under the License is distributed on an "AS IS" BASIS,
|
|
12
|
-
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
13
|
-
See the License for the specific language governing permissions and
|
|
14
|
-
limitations under the License.
|
|
15
|
-
**/
|
|
16
1
|
// @TODO
|
|
17
2
|
// 1- handle multiple protocols automatically
|
|
18
3
|
// 2- destroy it once the sdk is destroyed
|
|
19
4
|
import https from 'https';
|
|
20
5
|
var agent = new https.Agent({
|
|
21
|
-
|
|
22
|
-
|
|
6
|
+
keepAlive: true,
|
|
7
|
+
keepAliveMsecs: 1500
|
|
23
8
|
});
|
|
24
9
|
export function getOptions() {
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
}
|
|
10
|
+
return {
|
|
11
|
+
agent: agent
|
|
12
|
+
};
|
|
13
|
+
}
|
package/es/settings/browser.js
CHANGED
|
@@ -1,18 +1,18 @@
|
|
|
1
1
|
import { settingsValidation } from '@splitsoftware/splitio-commons/esm/utils/settingsValidation';
|
|
2
2
|
import { defaults } from './defaults/browser';
|
|
3
|
+
import { validateRuntime } from '@splitsoftware/splitio-commons/esm/utils/settingsValidation/runtime/browser';
|
|
3
4
|
import { validateStorage } from './storage/browser';
|
|
4
5
|
import { validateIntegrations } from './integrations/browser';
|
|
5
6
|
import { validateLogger } from '@splitsoftware/splitio-commons/esm/utils/settingsValidation/logger/builtinLogger';
|
|
6
7
|
import { LocalhostFromObject } from '@splitsoftware/splitio-commons/esm/sync/offline/LocalhostFromObject';
|
|
7
8
|
var params = {
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
return LocalhostFromObject();
|
|
14
|
-
}
|
|
9
|
+
defaults: defaults,
|
|
10
|
+
runtime: validateRuntime,
|
|
11
|
+
storage: validateStorage,
|
|
12
|
+
integrations: validateIntegrations,
|
|
13
|
+
logger: validateLogger,
|
|
14
|
+
localhost: function () { return LocalhostFromObject(); },
|
|
15
15
|
};
|
|
16
16
|
export function settingsFactory(config) {
|
|
17
|
-
|
|
18
|
-
}
|
|
17
|
+
return settingsValidation(config, params);
|
|
18
|
+
}
|
|
@@ -1,15 +1,15 @@
|
|
|
1
1
|
import { packageVersion } from './version';
|
|
2
2
|
export var defaults = {
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
};
|
|
3
|
+
startup: {
|
|
4
|
+
// Stress the request time used while starting up the SDK.
|
|
5
|
+
requestTimeoutBeforeReady: 5,
|
|
6
|
+
// How many quick retries we will do while starting up the SDK.
|
|
7
|
+
retriesOnFailureBeforeReady: 1,
|
|
8
|
+
// Maximum amount of time used before notifies me a timeout.
|
|
9
|
+
readyTimeout: 10,
|
|
10
|
+
// Amount of time we will wait before the first push of events.
|
|
11
|
+
eventsFirstPushWindow: 10
|
|
12
|
+
},
|
|
13
|
+
// Instance version.
|
|
14
|
+
version: "javascript-" + packageVersion,
|
|
15
|
+
};
|
|
@@ -1,24 +1,24 @@
|
|
|
1
1
|
import { packageVersion } from './version';
|
|
2
2
|
export var defaults = {
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
};
|
|
3
|
+
core: {
|
|
4
|
+
// Default is true.
|
|
5
|
+
IPAddressesEnabled: true
|
|
6
|
+
},
|
|
7
|
+
startup: {
|
|
8
|
+
// Stress the request time used while starting up the SDK.
|
|
9
|
+
requestTimeoutBeforeReady: 15,
|
|
10
|
+
// How many quick retries we will do while starting up the SDK.
|
|
11
|
+
retriesOnFailureBeforeReady: 1,
|
|
12
|
+
// Maximum amount of time used before notifies me a timeout.
|
|
13
|
+
readyTimeout: 15,
|
|
14
|
+
// Don't wait a specific time for first flush on Node, no page load here.
|
|
15
|
+
eventsFirstPushWindow: 0
|
|
16
|
+
},
|
|
17
|
+
scheduler: {
|
|
18
|
+
featuresRefreshRate: 5,
|
|
19
|
+
impressionsRefreshRate: 300
|
|
20
|
+
},
|
|
21
|
+
features: '.split',
|
|
22
|
+
// Instance version.
|
|
23
|
+
version: "nodejs-" + packageVersion,
|
|
24
|
+
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export var packageVersion = '10.17.3-rc.
|
|
1
|
+
export var packageVersion = '10.17.3-rc.3';
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { GOOGLE_ANALYTICS_TO_SPLIT, SPLIT_TO_GOOGLE_ANALYTICS } from '@splitsoftware/splitio-commons/esm/utils/constants/browser';
|
|
2
2
|
import { validateConfigurableIntegrations } from '@splitsoftware/splitio-commons/esm/utils/settingsValidation/integrations/configurable';
|
|
3
|
-
export
|
|
4
|
-
|
|
5
|
-
}
|
|
3
|
+
export function validateIntegrations(settings) {
|
|
4
|
+
return validateConfigurableIntegrations(settings, [GOOGLE_ANALYTICS_TO_SPLIT, SPLIT_TO_GOOGLE_ANALYTICS]);
|
|
5
|
+
}
|
package/es/settings/node.js
CHANGED
|
@@ -1,20 +1,17 @@
|
|
|
1
1
|
import { settingsValidation } from '@splitsoftware/splitio-commons/esm/utils/settingsValidation';
|
|
2
2
|
import { defaults } from './defaults/node';
|
|
3
|
-
import { validateRuntime } from '
|
|
3
|
+
import { validateRuntime } from '@splitsoftware/splitio-commons/esm/utils/settingsValidation/runtime/node';
|
|
4
4
|
import { validateStorage } from './storage/node';
|
|
5
|
-
import { validateIntegrations } from './integrations/node';
|
|
6
5
|
import { validateLogger } from '@splitsoftware/splitio-commons/esm/utils/settingsValidation/logger/builtinLogger';
|
|
7
6
|
import { LocalhostFromFile } from '@splitsoftware/splitio-commons/esm/sync/offline/LocalhostFromFile';
|
|
8
7
|
var params = {
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
return LocalhostFromFile();
|
|
16
|
-
}
|
|
8
|
+
defaults: defaults,
|
|
9
|
+
runtime: validateRuntime,
|
|
10
|
+
storage: validateStorage,
|
|
11
|
+
logger: validateLogger,
|
|
12
|
+
localhost: function () { return LocalhostFromFile(); },
|
|
13
|
+
// For now, Node SDK ignores settings.integrations, so no integration validator is passed
|
|
17
14
|
};
|
|
18
15
|
export function settingsFactory(config) {
|
|
19
|
-
|
|
20
|
-
}
|
|
16
|
+
return settingsValidation(config, params);
|
|
17
|
+
}
|
|
@@ -1,63 +1,35 @@
|
|
|
1
|
-
/**
|
|
2
|
-
Copyright 2022 Split Software
|
|
3
|
-
|
|
4
|
-
Licensed under the Apache License, Version 2.0 (the "License");
|
|
5
|
-
you may not use this file except in compliance with the License.
|
|
6
|
-
You may obtain a copy of the License at
|
|
7
|
-
|
|
8
|
-
http://www.apache.org/licenses/LICENSE-2.0
|
|
9
|
-
|
|
10
|
-
Unless required by applicable law or agreed to in writing, software
|
|
11
|
-
distributed under the License is distributed on an "AS IS" BASIS,
|
|
12
|
-
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
13
|
-
See the License for the specific language governing permissions and
|
|
14
|
-
limitations under the License.
|
|
15
|
-
**/
|
|
16
1
|
import { isLocalStorageAvailable } from '@splitsoftware/splitio-commons/esm/utils/env/isLocalStorageAvailable';
|
|
17
2
|
import { LOCALHOST_MODE, STORAGE_MEMORY } from '@splitsoftware/splitio-commons/esm/utils/constants';
|
|
18
3
|
var STORAGE_LOCALSTORAGE = 'LOCALSTORAGE';
|
|
19
4
|
export function validateStorage(settings) {
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
if (type !== STORAGE_MEMORY && type !== STORAGE_LOCALSTORAGE || type === STORAGE_LOCALSTORAGE && !isLocalStorageAvailable()) {
|
|
53
|
-
fallbackToMemory();
|
|
54
|
-
log.error('Invalid or unavailable storage. Fallbacking into MEMORY storage');
|
|
55
|
-
}
|
|
56
|
-
|
|
57
|
-
return {
|
|
58
|
-
type: type,
|
|
59
|
-
options: options,
|
|
60
|
-
prefix: prefix,
|
|
61
|
-
__originalType: __originalType
|
|
62
|
-
};
|
|
63
|
-
}
|
|
5
|
+
var log = settings.log, mode = settings.mode, _a = settings.storage, _b = _a === void 0 ? { type: STORAGE_MEMORY } : _a, type = _b.type, _c = _b.options, options = _c === void 0 ? {} : _c, prefix = _b.prefix;
|
|
6
|
+
var __originalType;
|
|
7
|
+
if (prefix) {
|
|
8
|
+
prefix += '.SPLITIO';
|
|
9
|
+
}
|
|
10
|
+
else {
|
|
11
|
+
prefix = 'SPLITIO';
|
|
12
|
+
}
|
|
13
|
+
var fallbackToMemory = function () {
|
|
14
|
+
__originalType = type;
|
|
15
|
+
type = STORAGE_MEMORY;
|
|
16
|
+
};
|
|
17
|
+
// In localhost mode, fallback to Memory storage and track original type to emit SDK_READY_FROM_CACHE if corresponds.
|
|
18
|
+
// ATM, other mode settings (e.g., 'consumer') are ignored in client-side API, and so treated as standalone.
|
|
19
|
+
if (mode === LOCALHOST_MODE && type === STORAGE_LOCALSTORAGE) {
|
|
20
|
+
fallbackToMemory();
|
|
21
|
+
}
|
|
22
|
+
// If an invalid storage type is provided OR we want to use LOCALSTORAGE and
|
|
23
|
+
// it's not available, fallback into MEMORY
|
|
24
|
+
if (type !== STORAGE_MEMORY && type !== STORAGE_LOCALSTORAGE ||
|
|
25
|
+
type === STORAGE_LOCALSTORAGE && !isLocalStorageAvailable()) {
|
|
26
|
+
fallbackToMemory();
|
|
27
|
+
log.error('Invalid or unavailable storage. Fallbacking into MEMORY storage');
|
|
28
|
+
}
|
|
29
|
+
return {
|
|
30
|
+
type: type,
|
|
31
|
+
options: options,
|
|
32
|
+
prefix: prefix,
|
|
33
|
+
__originalType: __originalType
|
|
34
|
+
};
|
|
35
|
+
}
|
|
@@ -1,95 +1,66 @@
|
|
|
1
|
-
/**
|
|
2
|
-
Copyright 2022 Split Software
|
|
3
|
-
|
|
4
|
-
Licensed under the Apache License, Version 2.0 (the "License");
|
|
5
|
-
you may not use this file except in compliance with the License.
|
|
6
|
-
You may obtain a copy of the License at
|
|
7
|
-
|
|
8
|
-
http://www.apache.org/licenses/LICENSE-2.0
|
|
9
|
-
|
|
10
|
-
Unless required by applicable law or agreed to in writing, software
|
|
11
|
-
distributed under the License is distributed on an "AS IS" BASIS,
|
|
12
|
-
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
13
|
-
See the License for the specific language governing permissions and
|
|
14
|
-
limitations under the License.
|
|
15
|
-
**/
|
|
16
1
|
import { LOCALHOST_MODE, STORAGE_MEMORY, STORAGE_REDIS, CONSUMER_MODE, STANDALONE_MODE } from '@splitsoftware/splitio-commons/esm/utils/constants';
|
|
17
2
|
export function validateStorage(settings) {
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
3
|
+
var log = settings.log, mode = settings.mode, _a = settings.storage, _b = _a === void 0 ? { type: STORAGE_MEMORY } : _a, type = _b.type, _c = _b.options, options = _c === void 0 ? {} : _c, prefix = _b.prefix;
|
|
4
|
+
if (prefix) {
|
|
5
|
+
prefix += '.SPLITIO';
|
|
6
|
+
}
|
|
7
|
+
else {
|
|
8
|
+
prefix = 'SPLITIO';
|
|
9
|
+
}
|
|
10
|
+
// We can have MEMORY, REDIS or an invalid storage type
|
|
11
|
+
switch (type) {
|
|
12
|
+
case STORAGE_REDIS: {
|
|
13
|
+
// If passing REDIS storage in localhost or standalone mode, we log an error and fallback to MEMORY storage
|
|
14
|
+
if (mode === STANDALONE_MODE || mode === LOCALHOST_MODE) {
|
|
15
|
+
log.error('The provided REDIS storage is invalid for this mode. It requires consumer mode. Fallbacking into default MEMORY storage.');
|
|
16
|
+
return {
|
|
17
|
+
type: STORAGE_MEMORY,
|
|
18
|
+
prefix: prefix
|
|
19
|
+
};
|
|
20
|
+
}
|
|
21
|
+
var host = options.host, port = options.port, db = options.db, pass = options.pass, url = options.url, connectionTimeout = options.connectionTimeout, operationTimeout = options.operationTimeout;
|
|
22
|
+
if (process.env.REDIS_HOST)
|
|
23
|
+
host = process.env.REDIS_HOST;
|
|
24
|
+
if (process.env.REDIS_PORT)
|
|
25
|
+
port = process.env.REDIS_PORT;
|
|
26
|
+
if (process.env.REDIS_DB)
|
|
27
|
+
db = process.env.REDIS_DB;
|
|
28
|
+
if (process.env.REDIS_PASS)
|
|
29
|
+
pass = process.env.REDIS_PASS;
|
|
30
|
+
if (process.env.REDIS_URL)
|
|
31
|
+
url = process.env.REDIS_URL;
|
|
32
|
+
var newOpts = {
|
|
33
|
+
connectionTimeout: connectionTimeout,
|
|
34
|
+
operationTimeout: operationTimeout
|
|
35
|
+
};
|
|
36
|
+
if (url) {
|
|
37
|
+
newOpts.url = url;
|
|
38
|
+
}
|
|
39
|
+
else {
|
|
40
|
+
newOpts.host = host;
|
|
41
|
+
newOpts.port = port;
|
|
42
|
+
newOpts.db = db;
|
|
43
|
+
newOpts.pass = pass;
|
|
44
|
+
}
|
|
45
|
+
return {
|
|
46
|
+
type: type,
|
|
47
|
+
prefix: prefix,
|
|
48
|
+
options: newOpts
|
|
49
|
+
};
|
|
46
50
|
}
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
var newOpts = {
|
|
61
|
-
connectionTimeout: connectionTimeout,
|
|
62
|
-
operationTimeout: operationTimeout
|
|
63
|
-
};
|
|
64
|
-
|
|
65
|
-
if (url) {
|
|
66
|
-
newOpts.url = url;
|
|
67
|
-
} else {
|
|
68
|
-
newOpts.host = host;
|
|
69
|
-
newOpts.port = port;
|
|
70
|
-
newOpts.db = db;
|
|
71
|
-
newOpts.pass = pass;
|
|
51
|
+
// For now, we don't have modifiers or settings for MEMORY in NodeJS
|
|
52
|
+
case STORAGE_MEMORY:
|
|
53
|
+
default: {
|
|
54
|
+
// If passing MEMORY storage in consumer mode, throw an error (no way to fallback to REDIS storage)
|
|
55
|
+
if (mode === CONSUMER_MODE)
|
|
56
|
+
throw new Error('A REDIS storage is required on consumer mode');
|
|
57
|
+
// If passing an invalid storage type, log an error
|
|
58
|
+
if (type !== STORAGE_MEMORY)
|
|
59
|
+
log.error("The provided '" + type + "' storage type is invalid. Fallbacking into default MEMORY storage.");
|
|
60
|
+
return {
|
|
61
|
+
type: STORAGE_MEMORY,
|
|
62
|
+
prefix: prefix
|
|
63
|
+
};
|
|
72
64
|
}
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
type: type,
|
|
76
|
-
prefix: prefix,
|
|
77
|
-
options: newOpts
|
|
78
|
-
};
|
|
79
|
-
}
|
|
80
|
-
// For now, we don't have modifiers or settings for MEMORY in NodeJS
|
|
81
|
-
|
|
82
|
-
case STORAGE_MEMORY:
|
|
83
|
-
default:
|
|
84
|
-
{
|
|
85
|
-
// If passing MEMORY storage in consumer mode, throw an error (no way to fallback to REDIS storage)
|
|
86
|
-
if (mode === CONSUMER_MODE) throw new Error('A REDIS storage is required on consumer mode'); // If passing an invalid storage type, log an error
|
|
87
|
-
|
|
88
|
-
if (type !== STORAGE_MEMORY) log.error("The provided '" + type + "' storage type is invalid. Fallbacking into default MEMORY storage.");
|
|
89
|
-
return {
|
|
90
|
-
type: STORAGE_MEMORY,
|
|
91
|
-
prefix: prefix
|
|
92
|
-
};
|
|
93
|
-
}
|
|
94
|
-
}
|
|
95
|
-
}
|
|
65
|
+
}
|
|
66
|
+
}
|
package/es/umd.js
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import { SplitFactory } from './index';
|
|
2
|
-
|
|
3
|
-
export default SplitFactory;
|
|
1
|
+
import { SplitFactory } from './index';
|
|
2
|
+
// eslint-disable-next-line import/no-default-export
|
|
3
|
+
export default SplitFactory;
|