@splitsoftware/splitio-commons 2.12.0 → 3.0.0-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 +19 -1
- package/cjs/evaluator/condition/engineUtils.js +2 -2
- package/cjs/evaluator/fallbackConfigsCalculator/fallbackSanitizer/index.js +70 -0
- package/cjs/evaluator/fallbackConfigsCalculator/index.js +25 -0
- package/cjs/evaluator/fallbackTreatmentsCalculator/fallbackSanitizer/index.js +5 -8
- package/cjs/evaluator/fallbackTreatmentsCalculator/index.js +21 -32
- package/cjs/evaluator/index.js +73 -48
- package/cjs/evaluator/matchers/whitelist.js +1 -1
- package/cjs/integrations/pluggable.js +1 -1
- package/cjs/listeners/browser.js +4 -3
- package/cjs/listeners/node.js +4 -4
- package/cjs/logger/constants.js +15 -21
- package/cjs/logger/index.js +1 -1
- package/cjs/logger/messages/debug.js +6 -7
- package/cjs/logger/messages/error.js +4 -4
- package/cjs/logger/messages/info.js +2 -4
- package/cjs/logger/messages/warn.js +9 -10
- package/cjs/platform/browser.js +15 -0
- package/cjs/platform/getEventSource/browser.js +8 -0
- package/cjs/platform/getEventSource/eventsource.js +480 -0
- package/cjs/platform/getEventSource/node.js +26 -0
- package/cjs/platform/getFetch/browser.js +9 -0
- package/cjs/platform/getFetch/node.js +27 -0
- package/cjs/platform/getOptions/node.js +25 -0
- package/cjs/platform/node.js +17 -0
- package/cjs/readiness/constants.js +5 -4
- package/cjs/readiness/readinessManager.js +22 -22
- package/cjs/readiness/sdkReadinessManager.js +0 -16
- package/cjs/sdkClient/client.js +9 -35
- package/cjs/sdkClient/clientAttributesDecoration.js +3 -3
- package/cjs/sdkClient/clientInputValidation.js +38 -81
- package/cjs/sdkClient/identity.js +1 -1
- package/cjs/sdkClient/sdkClient.js +4 -49
- package/cjs/sdkClient/sdkLifecycle.js +71 -0
- package/cjs/sdkClient/trackMethod.js +56 -0
- package/cjs/sdkFactory/index.js +13 -50
- package/cjs/sdkManager/index.js +5 -5
- package/cjs/services/authProvider.js +67 -0
- package/cjs/services/secureSplitHttpClient.js +39 -0
- package/cjs/services/splitApi.js +24 -14
- package/cjs/services/splitHttpClient.js +1 -1
- package/cjs/storages/AbstractDefinitionsCacheAsync.js +51 -0
- package/cjs/storages/AbstractDefinitionsCacheSync.js +76 -0
- package/cjs/storages/KeyBuilder.js +16 -16
- package/cjs/storages/KeyBuilderCS.js +17 -17
- package/cjs/storages/KeyBuilderSS.js +16 -16
- package/cjs/storages/getRolloutPlan.js +4 -4
- package/cjs/storages/inLocalStorage/DefinitionsCacheInLocal.js +194 -0
- package/cjs/storages/inLocalStorage/MySegmentsCacheInLocal.js +1 -1
- package/cjs/storages/inLocalStorage/RBSegmentsCacheInLocal.js +10 -10
- package/cjs/storages/inLocalStorage/index.js +6 -6
- package/cjs/storages/inLocalStorage/validateCache.js +3 -3
- package/cjs/storages/inMemory/DefinitionsCacheInMemory.js +121 -0
- package/cjs/storages/inMemory/ImpressionCountsCacheInMemory.js +1 -1
- package/cjs/storages/inMemory/InMemoryStorage.js +4 -4
- package/cjs/storages/inMemory/InMemoryStorageCS.js +5 -5
- package/cjs/storages/inMemory/MySegmentsCacheInMemory.js +1 -1
- package/cjs/storages/inMemory/RBSegmentsCacheInMemory.js +5 -5
- package/cjs/storages/inMemory/SegmentsCacheInMemory.js +1 -1
- package/cjs/storages/inMemory/TelemetryCacheInMemory.js +5 -5
- package/cjs/storages/inRedis/DefinitionsCacheInRedis.js +243 -0
- package/cjs/storages/inRedis/EventsCacheInRedis.js +1 -1
- package/cjs/storages/inRedis/ImpressionCountsCacheInRedis.js +5 -5
- package/cjs/storages/inRedis/ImpressionsCacheInRedis.js +1 -1
- package/cjs/storages/inRedis/RBSegmentsCacheInRedis.js +1 -1
- package/cjs/storages/inRedis/RedisAdapter.js +8 -8
- package/cjs/storages/inRedis/TelemetryCacheInRedis.js +7 -7
- package/cjs/storages/inRedis/UniqueKeysCacheInRedis.js +3 -3
- package/cjs/storages/inRedis/index.js +2 -2
- package/cjs/storages/pluggable/DefinitionsCachePluggable.js +212 -0
- package/cjs/storages/pluggable/EventsCachePluggable.js +1 -1
- package/cjs/storages/pluggable/ImpressionCountsCachePluggable.js +6 -6
- package/cjs/storages/pluggable/RBSegmentsCachePluggable.js +1 -1
- package/cjs/storages/pluggable/TelemetryCachePluggable.js +7 -7
- package/cjs/storages/pluggable/UniqueKeysCachePluggable.js +2 -2
- package/cjs/storages/pluggable/index.js +5 -5
- package/cjs/storages/pluggable/wrapperAdapter.js +1 -1
- package/cjs/storages/setRolloutPlan.js +6 -6
- package/cjs/storages/utils.js +6 -6
- package/cjs/sync/offline/splitsParser/parseCondition.js +1 -1
- package/cjs/sync/offline/syncTasks/fromObjectSyncTask.js +5 -5
- package/cjs/sync/polling/fetchers/segmentChangesFetcher.js +1 -1
- package/cjs/sync/polling/fetchers/splitChangesFetcher.js +24 -15
- package/cjs/sync/polling/pollingManagerCS.js +18 -18
- package/cjs/sync/polling/pollingManagerSS.js +13 -13
- package/cjs/sync/polling/syncTasks/definitionsSyncTask.js +12 -0
- package/cjs/sync/polling/updaters/{splitChangesUpdater.js → definitionChangesUpdater.js} +72 -64
- package/cjs/sync/polling/updaters/mySegmentsUpdater.js +3 -3
- package/cjs/sync/polling/updaters/segmentChangesUpdater.js +6 -6
- package/cjs/sync/streaming/SSEClient/index.js +2 -2
- package/cjs/sync/streaming/SSEHandler/NotificationKeeper.js +1 -1
- package/cjs/sync/streaming/SSEHandler/index.js +1 -1
- package/cjs/sync/streaming/UpdateWorkers/{SplitsUpdateWorker.js → DefinitionsUpdateWorker.js} +18 -18
- package/cjs/sync/streaming/UpdateWorkers/MySegmentsUpdateWorker.js +2 -2
- package/cjs/sync/streaming/UpdateWorkers/SegmentsUpdateWorker.js +2 -2
- package/cjs/sync/streaming/constants.js +3 -3
- package/cjs/sync/streaming/parseUtils.js +12 -12
- package/cjs/sync/streaming/pushManager.js +14 -14
- package/cjs/sync/submitters/impressionsSubmitter.js +6 -6
- package/cjs/sync/submitters/submitter.js +1 -1
- package/cjs/sync/submitters/telemetrySubmitter.js +1 -2
- package/cjs/sync/syncManagerOnline.js +9 -6
- package/cjs/trackers/eventTracker.js +10 -12
- package/cjs/trackers/impressionObserver/buildKey.js +1 -1
- package/cjs/trackers/impressionsTracker.js +37 -20
- package/cjs/trackers/uniqueKeysTracker.js +1 -1
- package/cjs/utils/Backoff.js +20 -0
- package/cjs/utils/EventEmitter.js +391 -0
- package/cjs/utils/filter/bloomFilter.js +37 -0
- package/cjs/utils/inputValidation/apiKey.js +1 -1
- package/cjs/utils/inputValidation/attribute.js +2 -2
- package/cjs/utils/inputValidation/{split.js → definition.js} +10 -10
- package/cjs/utils/inputValidation/{splitExistence.js → definitionExistence.js} +6 -6
- package/cjs/utils/inputValidation/definitions.js +25 -0
- package/cjs/utils/inputValidation/eventProperties.js +1 -1
- package/cjs/utils/inputValidation/index.js +7 -7
- package/cjs/utils/inputValidation/isOperational.js +4 -4
- package/cjs/utils/inputValidation/target.js +22 -0
- package/cjs/utils/labels/index.js +3 -3
- package/cjs/utils/lang/index.js +1 -1
- package/cjs/utils/lang/sets.js +4 -4
- package/cjs/utils/promise/timeout.js +1 -1
- package/cjs/utils/settingsValidation/splitFilters.js +4 -4
- package/cjs/utils/settingsValidation/url.js +6 -6
- package/esm/evaluator/condition/engineUtils.js +2 -2
- package/esm/evaluator/fallbackConfigsCalculator/fallbackSanitizer/index.js +64 -0
- package/esm/evaluator/fallbackConfigsCalculator/index.js +21 -0
- package/esm/evaluator/fallbackTreatmentsCalculator/fallbackSanitizer/index.js +5 -8
- package/esm/evaluator/fallbackTreatmentsCalculator/index.js +21 -33
- package/esm/evaluator/index.js +72 -48
- package/esm/evaluator/matchers/whitelist.js +1 -1
- package/esm/integrations/pluggable.js +1 -1
- package/esm/listeners/browser.js +4 -3
- package/esm/listeners/node.js +4 -4
- package/esm/logger/constants.js +12 -18
- package/esm/logger/index.js +1 -1
- package/esm/logger/messages/debug.js +5 -6
- package/esm/logger/messages/error.js +3 -3
- package/esm/logger/messages/info.js +1 -3
- package/esm/logger/messages/warn.js +8 -9
- package/esm/platform/browser.js +12 -0
- package/esm/platform/getEventSource/browser.js +4 -0
- package/esm/platform/getEventSource/eventsource.js +480 -0
- package/esm/platform/getEventSource/node.js +20 -0
- package/esm/platform/getFetch/browser.js +5 -0
- package/esm/platform/getFetch/node.js +22 -0
- package/esm/platform/getOptions/node.js +20 -0
- package/esm/platform/node.js +14 -0
- package/esm/readiness/constants.js +4 -3
- package/esm/readiness/readinessManager.js +23 -23
- package/esm/readiness/sdkReadinessManager.js +1 -17
- package/esm/sdkClient/client.js +10 -37
- package/esm/sdkClient/clientAttributesDecoration.js +3 -3
- package/esm/sdkClient/clientInputValidation.js +40 -83
- package/esm/sdkClient/identity.js +1 -1
- package/esm/sdkClient/sdkClient.js +4 -49
- package/esm/sdkClient/sdkLifecycle.js +67 -0
- package/esm/sdkClient/trackMethod.js +52 -0
- package/esm/sdkFactory/index.js +14 -51
- package/esm/sdkManager/index.js +6 -6
- package/esm/services/authProvider.js +63 -0
- package/esm/services/secureSplitHttpClient.js +35 -0
- package/esm/services/splitApi.js +24 -14
- package/esm/services/splitHttpClient.js +1 -1
- package/esm/storages/AbstractDefinitionsCacheAsync.js +48 -0
- package/esm/storages/AbstractDefinitionsCacheSync.js +71 -0
- package/esm/storages/KeyBuilder.js +16 -16
- package/esm/storages/KeyBuilderCS.js +16 -16
- package/esm/storages/KeyBuilderSS.js +15 -15
- package/esm/storages/getRolloutPlan.js +4 -4
- package/esm/storages/inLocalStorage/DefinitionsCacheInLocal.js +191 -0
- package/esm/storages/inLocalStorage/RBSegmentsCacheInLocal.js +7 -7
- package/esm/storages/inLocalStorage/index.js +6 -6
- package/esm/storages/inLocalStorage/validateCache.js +3 -3
- package/esm/storages/inMemory/DefinitionsCacheInMemory.js +118 -0
- package/esm/storages/inMemory/ImpressionCountsCacheInMemory.js +1 -1
- package/esm/storages/inMemory/InMemoryStorage.js +4 -4
- package/esm/storages/inMemory/InMemoryStorageCS.js +5 -5
- package/esm/storages/inMemory/RBSegmentsCacheInMemory.js +2 -2
- package/esm/storages/inMemory/SegmentsCacheInMemory.js +1 -1
- package/esm/storages/inMemory/TelemetryCacheInMemory.js +5 -5
- package/esm/storages/inRedis/DefinitionsCacheInRedis.js +240 -0
- package/esm/storages/inRedis/EventsCacheInRedis.js +1 -1
- package/esm/storages/inRedis/ImpressionCountsCacheInRedis.js +4 -4
- package/esm/storages/inRedis/RBSegmentsCacheInRedis.js +1 -1
- package/esm/storages/inRedis/RedisAdapter.js +7 -7
- package/esm/storages/inRedis/TelemetryCacheInRedis.js +7 -7
- package/esm/storages/inRedis/UniqueKeysCacheInRedis.js +1 -1
- package/esm/storages/inRedis/index.js +2 -2
- package/esm/storages/pluggable/DefinitionsCachePluggable.js +209 -0
- package/esm/storages/pluggable/EventsCachePluggable.js +1 -1
- package/esm/storages/pluggable/ImpressionCountsCachePluggable.js +5 -5
- package/esm/storages/pluggable/RBSegmentsCachePluggable.js +1 -1
- package/esm/storages/pluggable/TelemetryCachePluggable.js +7 -7
- package/esm/storages/pluggable/UniqueKeysCachePluggable.js +1 -1
- package/esm/storages/pluggable/index.js +4 -4
- package/esm/storages/pluggable/wrapperAdapter.js +1 -1
- package/esm/storages/setRolloutPlan.js +6 -6
- package/esm/storages/utils.js +6 -6
- package/esm/sync/offline/splitsParser/parseCondition.js +1 -1
- package/esm/sync/offline/syncTasks/fromObjectSyncTask.js +6 -6
- package/esm/sync/polling/fetchers/splitChangesFetcher.js +25 -16
- package/esm/sync/polling/pollingManagerCS.js +15 -15
- package/esm/sync/polling/pollingManagerSS.js +13 -13
- package/esm/sync/polling/syncTasks/definitionsSyncTask.js +8 -0
- package/esm/sync/polling/updaters/definitionChangesUpdater.js +200 -0
- package/esm/sync/polling/updaters/mySegmentsUpdater.js +3 -3
- package/esm/sync/polling/updaters/segmentChangesUpdater.js +7 -7
- package/esm/sync/streaming/SSEClient/index.js +2 -2
- package/esm/sync/streaming/SSEHandler/NotificationKeeper.js +2 -2
- package/esm/sync/streaming/SSEHandler/index.js +2 -2
- package/esm/sync/streaming/UpdateWorkers/{SplitsUpdateWorker.js → DefinitionsUpdateWorker.js} +17 -17
- package/esm/sync/streaming/UpdateWorkers/MySegmentsUpdateWorker.js +2 -2
- package/esm/sync/streaming/UpdateWorkers/SegmentsUpdateWorker.js +2 -2
- package/esm/sync/streaming/constants.js +2 -2
- package/esm/sync/streaming/parseUtils.js +10 -10
- package/esm/sync/streaming/pushManager.js +16 -16
- package/esm/sync/submitters/impressionsSubmitter.js +6 -6
- package/esm/sync/submitters/submitter.js +1 -1
- package/esm/sync/submitters/telemetrySubmitter.js +1 -2
- package/esm/sync/syncManagerOnline.js +8 -5
- package/esm/trackers/eventTracker.js +10 -12
- package/esm/trackers/impressionObserver/buildKey.js +1 -1
- package/esm/trackers/impressionsTracker.js +38 -21
- package/esm/trackers/uniqueKeysTracker.js +1 -1
- package/esm/utils/Backoff.js +20 -0
- package/esm/utils/EventEmitter.js +387 -0
- package/esm/utils/filter/bloomFilter.js +33 -0
- package/esm/utils/inputValidation/apiKey.js +1 -1
- package/esm/utils/inputValidation/attribute.js +2 -2
- package/esm/utils/inputValidation/{split.js → definition.js} +8 -8
- package/esm/utils/inputValidation/definitionExistence.js +15 -0
- package/esm/utils/inputValidation/definitions.js +21 -0
- package/esm/utils/inputValidation/index.js +3 -3
- package/esm/utils/inputValidation/isOperational.js +4 -4
- package/esm/utils/inputValidation/target.js +18 -0
- package/esm/utils/labels/index.js +2 -2
- package/esm/utils/lang/sets.js +4 -4
- package/esm/utils/promise/timeout.js +1 -1
- package/esm/utils/settingsValidation/splitFilters.js +4 -4
- package/esm/utils/settingsValidation/url.js +6 -6
- package/package.json +15 -6
- package/src/dtos/types.ts +65 -70
- package/src/evaluator/Engine.ts +4 -4
- package/src/evaluator/combiners/and.ts +3 -3
- package/src/evaluator/combiners/ifelseif.ts +2 -2
- package/src/evaluator/condition/engineUtils.ts +2 -2
- package/src/evaluator/condition/index.ts +3 -3
- package/src/evaluator/fallbackConfigsCalculator/fallbackSanitizer/index.ts +76 -0
- package/src/evaluator/fallbackConfigsCalculator/index.ts +24 -0
- package/src/evaluator/fallbackTreatmentsCalculator/fallbackSanitizer/index.ts +5 -7
- package/src/evaluator/fallbackTreatmentsCalculator/index.ts +27 -41
- package/src/evaluator/index.ts +86 -51
- package/src/evaluator/matchers/dependency.ts +2 -2
- package/src/evaluator/matchers/matcherTypes.ts +2 -2
- package/src/evaluator/matchers/prerequisites.ts +4 -4
- package/src/evaluator/matchers/rbsegment.ts +2 -2
- package/src/evaluator/matchers/whitelist.ts +2 -2
- package/src/evaluator/matchersTransform/index.ts +2 -2
- package/src/evaluator/matchersTransform/whitelist.ts +2 -2
- package/src/evaluator/parser/index.ts +4 -4
- package/src/evaluator/treatments/index.ts +2 -2
- package/src/evaluator/types.ts +6 -6
- package/src/evaluator/value/index.ts +1 -1
- package/src/integrations/pluggable.ts +1 -1
- package/src/listeners/browser.ts +11 -8
- package/src/listeners/node.ts +2 -5
- package/src/logger/constants.ts +12 -18
- package/src/logger/messages/debug.ts +5 -6
- package/src/logger/messages/error.ts +3 -3
- package/src/logger/messages/info.ts +1 -3
- package/src/logger/messages/warn.ts +8 -9
- package/src/platform/browser.ts +14 -0
- package/src/platform/getEventSource/browser.ts +4 -0
- package/src/platform/getEventSource/eventsource.js +519 -0
- package/src/platform/getEventSource/node.ts +23 -0
- package/src/platform/getFetch/browser.ts +5 -0
- package/src/platform/getFetch/node.ts +27 -0
- package/src/platform/getOptions/node.ts +24 -0
- package/src/platform/node.ts +16 -0
- package/src/readiness/constants.ts +4 -3
- package/src/readiness/readinessManager.ts +22 -22
- package/src/readiness/sdkReadinessManager.ts +1 -16
- package/src/readiness/types.ts +10 -16
- package/src/sdkClient/client.ts +11 -41
- package/src/sdkClient/clientInputValidation.ts +44 -84
- package/src/sdkClient/sdkClient.ts +5 -54
- package/src/sdkClient/sdkLifecycle.ts +79 -0
- package/src/sdkClient/trackMethod.ts +59 -0
- package/src/sdkFactory/index.ts +15 -59
- package/src/sdkFactory/types.ts +19 -16
- package/src/sdkManager/index.ts +15 -15
- package/src/services/authProvider.ts +86 -0
- package/src/services/secureSplitHttpClient.ts +44 -0
- package/src/services/splitApi.ts +14 -2
- package/src/services/types.ts +7 -2
- package/src/storages/AbstractDefinitionsCacheAsync.ts +63 -0
- package/src/storages/AbstractDefinitionsCacheSync.ts +95 -0
- package/src/storages/KeyBuilder.ts +6 -6
- package/src/storages/KeyBuilderCS.ts +6 -6
- package/src/storages/KeyBuilderSS.ts +2 -2
- package/src/storages/getRolloutPlan.ts +3 -3
- package/src/storages/inLocalStorage/DefinitionsCacheInLocal.ts +234 -0
- package/src/storages/inLocalStorage/RBSegmentsCacheInLocal.ts +8 -8
- package/src/storages/inLocalStorage/index.ts +6 -6
- package/src/storages/inLocalStorage/validateCache.ts +4 -4
- package/src/storages/inMemory/DefinitionsCacheInMemory.ts +130 -0
- package/src/storages/inMemory/InMemoryStorage.ts +4 -4
- package/src/storages/inMemory/InMemoryStorageCS.ts +5 -5
- package/src/storages/inMemory/RBSegmentsCacheInMemory.ts +3 -3
- package/src/storages/inMemory/SegmentsCacheInMemory.ts +1 -1
- package/src/storages/inMemory/TelemetryCacheInMemory.ts +5 -5
- package/src/storages/inRedis/{SplitsCacheInRedis.ts → DefinitionsCacheInRedis.ts} +69 -69
- package/src/storages/inRedis/RBSegmentsCacheInRedis.ts +2 -2
- package/src/storages/inRedis/index.ts +2 -2
- package/src/storages/pluggable/DefinitionsCachePluggable.ts +230 -0
- package/src/storages/pluggable/RBSegmentsCachePluggable.ts +2 -2
- package/src/storages/pluggable/index.ts +2 -2
- package/src/storages/setRolloutPlan.ts +7 -7
- package/src/storages/types.ts +34 -29
- package/src/sync/offline/splitsParser/parseCondition.ts +2 -2
- package/src/sync/offline/splitsParser/splitsParserFromSettings.ts +3 -3
- package/src/sync/offline/splitsParser/types.ts +6 -3
- package/src/sync/offline/syncManagerOffline.ts +2 -2
- package/src/sync/offline/syncTasks/fromObjectSyncTask.ts +14 -14
- package/src/sync/polling/fetchers/splitChangesFetcher.ts +58 -23
- package/src/sync/polling/fetchers/types.ts +5 -3
- package/src/sync/polling/pollingManagerCS.ts +16 -14
- package/src/sync/polling/pollingManagerSS.ts +15 -13
- package/src/sync/polling/syncTasks/{splitsSyncTask.ts → definitionsSyncTask.ts} +11 -12
- package/src/sync/polling/types.ts +3 -3
- package/src/sync/polling/updaters/definitionChangesUpdater.ts +239 -0
- package/src/sync/polling/updaters/mySegmentsUpdater.ts +3 -3
- package/src/sync/polling/updaters/segmentChangesUpdater.ts +7 -7
- package/src/sync/streaming/AuthClient/index.ts +2 -2
- package/src/sync/streaming/AuthClient/types.ts +14 -11
- package/src/sync/streaming/SSEClient/index.ts +2 -2
- package/src/sync/streaming/SSEClient/types.ts +2 -2
- package/src/sync/streaming/SSEHandler/NotificationKeeper.ts +2 -2
- package/src/sync/streaming/SSEHandler/index.ts +2 -2
- package/src/sync/streaming/UpdateWorkers/{SplitsUpdateWorker.ts → DefinitionsUpdateWorker.ts} +21 -21
- package/src/sync/streaming/constants.ts +2 -2
- package/src/sync/streaming/parseUtils.ts +12 -12
- package/src/sync/streaming/pushManager.ts +18 -18
- package/src/sync/streaming/types.ts +2 -2
- package/src/sync/submitters/impressionsSubmitter.ts +9 -9
- package/src/sync/submitters/telemetrySubmitter.ts +1 -2
- package/src/sync/submitters/types.ts +3 -0
- package/src/sync/syncManagerOnline.ts +9 -5
- package/src/trackers/eventTracker.ts +7 -10
- package/src/trackers/impressionsTracker.ts +42 -26
- package/src/trackers/types.ts +3 -1
- package/src/utils/Backoff.ts +21 -0
- package/src/utils/EventEmitter.js +444 -0
- package/src/utils/filter/bloomFilter.ts +38 -0
- package/src/utils/inputValidation/definition.ts +27 -0
- package/src/utils/inputValidation/definitionExistence.ts +19 -0
- package/src/utils/inputValidation/definitions.ts +21 -0
- package/src/utils/inputValidation/index.ts +3 -3
- package/src/utils/inputValidation/isOperational.ts +4 -4
- package/src/utils/inputValidation/target.ts +21 -0
- package/src/utils/inputValidation/trafficTypeExistence.ts +2 -2
- package/src/utils/jwt/types.ts +1 -1
- package/src/utils/labels/index.ts +2 -2
- package/src/utils/lang/sets.ts +4 -2
- package/src/utils/settingsValidation/splitFilters.ts +3 -3
- package/src/utils/settingsValidation/url.ts +1 -1
- package/types/splitio.d.ts +222 -11
- package/cjs/storages/AbstractSplitsCacheAsync.js +0 -51
- package/cjs/storages/AbstractSplitsCacheSync.js +0 -76
- package/cjs/storages/inLocalStorage/SplitsCacheInLocal.js +0 -194
- package/cjs/storages/inMemory/SplitsCacheInMemory.js +0 -121
- package/cjs/storages/inRedis/SplitsCacheInRedis.js +0 -243
- package/cjs/storages/pluggable/SplitsCachePluggable.js +0 -212
- package/cjs/sync/polling/syncTasks/splitsSyncTask.js +0 -13
- package/cjs/utils/inputValidation/splits.js +0 -25
- package/esm/storages/AbstractSplitsCacheAsync.js +0 -48
- package/esm/storages/AbstractSplitsCacheSync.js +0 -71
- package/esm/storages/inLocalStorage/SplitsCacheInLocal.js +0 -191
- package/esm/storages/inMemory/SplitsCacheInMemory.js +0 -118
- package/esm/storages/inRedis/SplitsCacheInRedis.js +0 -240
- package/esm/storages/pluggable/SplitsCachePluggable.js +0 -209
- package/esm/sync/polling/syncTasks/splitsSyncTask.js +0 -9
- package/esm/sync/polling/updaters/splitChangesUpdater.js +0 -192
- package/esm/utils/inputValidation/splitExistence.js +0 -15
- package/esm/utils/inputValidation/splits.js +0 -21
- package/src/storages/AbstractSplitsCacheAsync.ts +0 -63
- package/src/storages/AbstractSplitsCacheSync.ts +0 -95
- package/src/storages/inLocalStorage/SplitsCacheInLocal.ts +0 -234
- package/src/storages/inMemory/SplitsCacheInMemory.ts +0 -130
- package/src/storages/pluggable/SplitsCachePluggable.ts +0 -230
- package/src/sync/polling/updaters/splitChangesUpdater.ts +0 -230
- package/src/utils/inputValidation/split.ts +0 -27
- package/src/utils/inputValidation/splitExistence.ts +0 -19
- package/src/utils/inputValidation/splits.ts +0 -21
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { setToArray } from '../../utils/lang/sets';
|
|
2
|
-
import { usesSegments } from '../
|
|
2
|
+
import { usesSegments } from '../AbstractDefinitionsCacheSync';
|
|
3
3
|
var RBSegmentsCacheInMemory = /** @class */ (function () {
|
|
4
4
|
function RBSegmentsCacheInMemory() {
|
|
5
5
|
this.cache = {};
|
|
@@ -14,7 +14,7 @@ var RBSegmentsCacheInMemory = /** @class */ (function () {
|
|
|
14
14
|
RBSegmentsCacheInMemory.prototype.update = function (toAdd, toRemove, changeNumber) {
|
|
15
15
|
var _this = this;
|
|
16
16
|
var updated = toAdd.map(function (toAdd) { return _this.add(toAdd); }).some(function (result) { return result; });
|
|
17
|
-
updated = toRemove.map(function (toRemove) { return _this.remove(toRemove
|
|
17
|
+
updated = toRemove.map(function (toRemove) { return _this.remove(toRemove); }).some(function (result) { return result; }) || updated;
|
|
18
18
|
this.changeNumber = changeNumber;
|
|
19
19
|
return updated;
|
|
20
20
|
};
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { isIntegerNumber } from '../../utils/lang';
|
|
2
2
|
/**
|
|
3
|
-
* Default
|
|
3
|
+
* Default IDefinitionsCacheSync implementation for server-side that stores segments definitions in memory.
|
|
4
4
|
*/
|
|
5
5
|
var SegmentsCacheInMemory = /** @class */ (function () {
|
|
6
6
|
function SegmentsCacheInMemory() {
|
|
@@ -15,12 +15,12 @@ var ACCEPTANCE_RANGE = 0.001;
|
|
|
15
15
|
* All factory instances track telemetry on server-side, and 0.1% on client-side.
|
|
16
16
|
*/
|
|
17
17
|
export function shouldRecordTelemetry(_a) {
|
|
18
|
-
var settings = _a.settings;
|
|
19
|
-
return settings.mode !== LOCALHOST_MODE && (checkIfServerSide(settings) || Math.random() <= ACCEPTANCE_RANGE);
|
|
18
|
+
var settings = _a.settings, disableTelemetry = _a.disableTelemetry;
|
|
19
|
+
return !disableTelemetry && settings.mode !== LOCALHOST_MODE && (checkIfServerSide(settings) || Math.random() <= ACCEPTANCE_RANGE);
|
|
20
20
|
}
|
|
21
21
|
var TelemetryCacheInMemory = /** @class */ (function () {
|
|
22
|
-
function TelemetryCacheInMemory(
|
|
23
|
-
this.
|
|
22
|
+
function TelemetryCacheInMemory(definitions, segments, largeSegments) {
|
|
23
|
+
this.definitions = definitions;
|
|
24
24
|
this.segments = segments;
|
|
25
25
|
this.largeSegments = largeSegments;
|
|
26
26
|
this.name = 'telemetry stats';
|
|
@@ -56,7 +56,7 @@ var TelemetryCacheInMemory = /** @class */ (function () {
|
|
|
56
56
|
iQ: this.getImpressionStats(QUEUED),
|
|
57
57
|
iDe: this.getImpressionStats(DEDUPED),
|
|
58
58
|
iDr: this.getImpressionStats(DROPPED),
|
|
59
|
-
spC: this.
|
|
59
|
+
spC: this.definitions && this.definitions.getNames().length,
|
|
60
60
|
seC: this.segments && this.segments.getRegisteredSegments().length,
|
|
61
61
|
skC: this.segments && this.segments.getKeysCount(),
|
|
62
62
|
lsC: this.largeSegments && this.largeSegments.getRegisteredSegments().length,
|
|
@@ -0,0 +1,240 @@
|
|
|
1
|
+
import { __extends, __spreadArray } from "tslib";
|
|
2
|
+
import { isFiniteNumber, isNaNNumber } from '../../utils/lang';
|
|
3
|
+
import { LOG_PREFIX } from './constants';
|
|
4
|
+
import { AbstractDefinitionsCacheAsync } from '../AbstractDefinitionsCacheAsync';
|
|
5
|
+
import { returnDifference } from '../../utils/lang/sets';
|
|
6
|
+
/**
|
|
7
|
+
* Discard errors for an answer of multiple operations.
|
|
8
|
+
*/
|
|
9
|
+
function processPipelineAnswer(results) {
|
|
10
|
+
return results ? results.reduce(function (accum, errValuePair) {
|
|
11
|
+
if (errValuePair[0] === null)
|
|
12
|
+
accum.push(errValuePair[1]);
|
|
13
|
+
return accum;
|
|
14
|
+
}, []) : [];
|
|
15
|
+
}
|
|
16
|
+
/**
|
|
17
|
+
* IDefinitionsCacheAsync implementation that stores definitions in Redis.
|
|
18
|
+
* Supported by Node.js
|
|
19
|
+
*/
|
|
20
|
+
var DefinitionsCacheInRedis = /** @class */ (function (_super) {
|
|
21
|
+
__extends(DefinitionsCacheInRedis, _super);
|
|
22
|
+
function DefinitionsCacheInRedis(log, keys, redis, splitFiltersValidation) {
|
|
23
|
+
var _this = _super.call(this) || this;
|
|
24
|
+
_this.log = log;
|
|
25
|
+
_this.redis = redis;
|
|
26
|
+
_this.keys = keys;
|
|
27
|
+
_this.setsFilter = splitFiltersValidation ? splitFiltersValidation.groupedFilters.bySet : [];
|
|
28
|
+
// There is no need to listen for redis 'error' event, because in that case ioredis calls will be rejected and handled by redis storage adapters.
|
|
29
|
+
// But it is done just to avoid getting the ioredis message `Unhandled error event`.
|
|
30
|
+
_this.redis.on('error', function (e) {
|
|
31
|
+
_this.redisError = e;
|
|
32
|
+
});
|
|
33
|
+
_this.redis.on('connect', function () {
|
|
34
|
+
_this.redisError = undefined;
|
|
35
|
+
});
|
|
36
|
+
return _this;
|
|
37
|
+
}
|
|
38
|
+
DefinitionsCacheInRedis.prototype._decrementCounts = function (definition) {
|
|
39
|
+
var _this = this;
|
|
40
|
+
var ttKey = this.keys.buildTrafficTypeKey(definition.trafficTypeName);
|
|
41
|
+
return this.redis.decr(ttKey).then(function (count) {
|
|
42
|
+
if (count === 0)
|
|
43
|
+
return _this.redis.del(ttKey);
|
|
44
|
+
});
|
|
45
|
+
};
|
|
46
|
+
DefinitionsCacheInRedis.prototype._incrementCounts = function (definition) {
|
|
47
|
+
var ttKey = this.keys.buildTrafficTypeKey(definition.trafficTypeName);
|
|
48
|
+
return this.redis.incr(ttKey);
|
|
49
|
+
};
|
|
50
|
+
DefinitionsCacheInRedis.prototype._updateSets = function (definitionName, setsOfRemovedDefinition, setsOfAddedDefinition) {
|
|
51
|
+
var _this = this;
|
|
52
|
+
var removeFromSets = returnDifference(setsOfRemovedDefinition, setsOfAddedDefinition);
|
|
53
|
+
var addToSets = returnDifference(setsOfAddedDefinition, setsOfRemovedDefinition);
|
|
54
|
+
if (this.setsFilter.length > 0) {
|
|
55
|
+
addToSets = addToSets.filter(function (set) {
|
|
56
|
+
return _this.setsFilter.some(function (filterSet) { return filterSet === set; });
|
|
57
|
+
});
|
|
58
|
+
}
|
|
59
|
+
var items = [definitionName];
|
|
60
|
+
return Promise.all(__spreadArray(__spreadArray([], removeFromSets.map(function (setName) { return _this.redis.srem(_this.keys.buildSetKey(setName), items); }), true), addToSets.map(function (setName) { return _this.redis.sadd(_this.keys.buildSetKey(setName), items); }), true));
|
|
61
|
+
};
|
|
62
|
+
/**
|
|
63
|
+
* Add a given definition.
|
|
64
|
+
* The returned promise is resolved when the operation success
|
|
65
|
+
* or rejected if it fails (e.g., redis operation fails)
|
|
66
|
+
*/
|
|
67
|
+
DefinitionsCacheInRedis.prototype.add = function (definition) {
|
|
68
|
+
var _this = this;
|
|
69
|
+
var name = definition.name;
|
|
70
|
+
var definitionKey = this.keys.buildDefinitionKey(name);
|
|
71
|
+
return this.redis.get(definitionKey).then(function (definitionFromStorage) {
|
|
72
|
+
// handling parsing error
|
|
73
|
+
var parsedPreviousDefinition, stringifiedNewDefinition;
|
|
74
|
+
try {
|
|
75
|
+
parsedPreviousDefinition = definitionFromStorage ? JSON.parse(definitionFromStorage) : undefined;
|
|
76
|
+
stringifiedNewDefinition = JSON.stringify(definition);
|
|
77
|
+
}
|
|
78
|
+
catch (e) {
|
|
79
|
+
throw new Error('Error parsing feature flag definition: ' + e);
|
|
80
|
+
}
|
|
81
|
+
return _this.redis.set(definitionKey, stringifiedNewDefinition).then(function () {
|
|
82
|
+
// avoid unnecessary increment/decrement operations
|
|
83
|
+
if (parsedPreviousDefinition && parsedPreviousDefinition.trafficTypeName === definition.trafficTypeName)
|
|
84
|
+
return;
|
|
85
|
+
// update traffic type counts
|
|
86
|
+
return _this._incrementCounts(definition).then(function () {
|
|
87
|
+
if (parsedPreviousDefinition)
|
|
88
|
+
return _this._decrementCounts(parsedPreviousDefinition);
|
|
89
|
+
});
|
|
90
|
+
}).then(function () { return _this._updateSets(name, parsedPreviousDefinition && parsedPreviousDefinition.sets, definition.sets); });
|
|
91
|
+
}).then(function () { return true; });
|
|
92
|
+
};
|
|
93
|
+
/**
|
|
94
|
+
* Remove a given definition.
|
|
95
|
+
* The returned promise is resolved when the operation success, with true or false indicating if the definition existed (and was removed) or not.
|
|
96
|
+
* or rejected if it fails (e.g., redis operation fails).
|
|
97
|
+
*/
|
|
98
|
+
DefinitionsCacheInRedis.prototype.remove = function (name) {
|
|
99
|
+
var _this = this;
|
|
100
|
+
return this.get(name).then(function (definition) {
|
|
101
|
+
if (definition) {
|
|
102
|
+
return _this._decrementCounts(definition).then(function () { return _this._updateSets(name, definition.sets); });
|
|
103
|
+
}
|
|
104
|
+
}).then(function () {
|
|
105
|
+
return _this.redis.del(_this.keys.buildDefinitionKey(name)).then(function (status) { return status === 1; });
|
|
106
|
+
});
|
|
107
|
+
};
|
|
108
|
+
/**
|
|
109
|
+
* Get definition or null if it's not defined.
|
|
110
|
+
* Returned promise is rejected if redis operation fails.
|
|
111
|
+
*/
|
|
112
|
+
DefinitionsCacheInRedis.prototype.get = function (name) {
|
|
113
|
+
if (this.redisError) {
|
|
114
|
+
this.log.error(LOG_PREFIX + this.redisError);
|
|
115
|
+
return Promise.reject(this.redisError);
|
|
116
|
+
}
|
|
117
|
+
return this.redis.get(this.keys.buildDefinitionKey(name))
|
|
118
|
+
.then(function (maybeDefinition) { return maybeDefinition && JSON.parse(maybeDefinition); });
|
|
119
|
+
};
|
|
120
|
+
/**
|
|
121
|
+
* Set till number.
|
|
122
|
+
* The returned promise is resolved when the operation success,
|
|
123
|
+
* or rejected if it fails.
|
|
124
|
+
*/
|
|
125
|
+
DefinitionsCacheInRedis.prototype.setChangeNumber = function (changeNumber) {
|
|
126
|
+
return this.redis.set(this.keys.buildDefinitionsTillKey(), changeNumber + '').then(function (status) { return status === 'OK'; });
|
|
127
|
+
};
|
|
128
|
+
/**
|
|
129
|
+
* Get till number or -1 if it's not defined.
|
|
130
|
+
* The returned promise is resolved with the changeNumber or -1 if it doesn't exist or a redis operation fails.
|
|
131
|
+
* The promise will never be rejected.
|
|
132
|
+
*/
|
|
133
|
+
DefinitionsCacheInRedis.prototype.getChangeNumber = function () {
|
|
134
|
+
var _this = this;
|
|
135
|
+
return this.redis.get(this.keys.buildDefinitionsTillKey()).then(function (value) {
|
|
136
|
+
var i = parseInt(value, 10);
|
|
137
|
+
return isNaNNumber(i) ? -1 : i;
|
|
138
|
+
}).catch(function (e) {
|
|
139
|
+
_this.log.error(LOG_PREFIX + 'Could not retrieve changeNumber from storage. Error: ' + e);
|
|
140
|
+
return -1;
|
|
141
|
+
});
|
|
142
|
+
};
|
|
143
|
+
/**
|
|
144
|
+
* Get list of all definitions.
|
|
145
|
+
* The returned promise is resolved with the list of definitions,
|
|
146
|
+
* or rejected if redis operation fails.
|
|
147
|
+
*/
|
|
148
|
+
// @TODO we need to benchmark which is the maximun number of commands we could pipeline without kill redis performance.
|
|
149
|
+
DefinitionsCacheInRedis.prototype.getAll = function () {
|
|
150
|
+
var _this = this;
|
|
151
|
+
return this.redis.keys(this.keys.searchPatternForDefinitionKeys())
|
|
152
|
+
.then(function (listOfKeys) { return _this.redis.pipeline(listOfKeys.map(function (k) { return ['get', k]; })).exec(); })
|
|
153
|
+
.then(processPipelineAnswer)
|
|
154
|
+
.then(function (definitions) { return definitions.map(function (definition) {
|
|
155
|
+
return JSON.parse(definition);
|
|
156
|
+
}); });
|
|
157
|
+
};
|
|
158
|
+
/**
|
|
159
|
+
* Get list of definition names.
|
|
160
|
+
* The returned promise is resolved with the list of names,
|
|
161
|
+
* or rejected if redis operation fails.
|
|
162
|
+
*/
|
|
163
|
+
DefinitionsCacheInRedis.prototype.getNames = function () {
|
|
164
|
+
var _this = this;
|
|
165
|
+
return this.redis.keys(this.keys.searchPatternForDefinitionKeys()).then(function (listOfKeys) { return listOfKeys.map(_this.keys.extractKey); });
|
|
166
|
+
};
|
|
167
|
+
/**
|
|
168
|
+
* Get list of definition names related to a given list of set names.
|
|
169
|
+
* The returned promise is resolved with the list of names per set,
|
|
170
|
+
* or rejected if the pipelined redis operation fails (e.g., timeout).
|
|
171
|
+
*/
|
|
172
|
+
DefinitionsCacheInRedis.prototype.getNamesBySets = function (sets) {
|
|
173
|
+
var _this = this;
|
|
174
|
+
return this.redis.pipeline(sets.map(function (set) { return ['smembers', _this.keys.buildSetKey(set)]; })).exec()
|
|
175
|
+
.then(function (results) { return results ? results.map(function (_a, index) {
|
|
176
|
+
var e = _a[0], value = _a[1];
|
|
177
|
+
if (e === null)
|
|
178
|
+
return value;
|
|
179
|
+
_this.log.error(LOG_PREFIX + "Could not read result from get members of set ".concat(sets[index], " due to an error: ").concat(e));
|
|
180
|
+
}) : []; })
|
|
181
|
+
.then(function (namesBySets) { return namesBySets.map(function (namesBySet) { return new Set(namesBySet); }); });
|
|
182
|
+
};
|
|
183
|
+
/**
|
|
184
|
+
* Check traffic type existence.
|
|
185
|
+
* The returned promise is resolved with a boolean indicating whether the TT exist or not.
|
|
186
|
+
* In case of redis operation failure, the promise resolves with a true value, assuming that the TT might exist.
|
|
187
|
+
* It will never be rejected.
|
|
188
|
+
*/
|
|
189
|
+
DefinitionsCacheInRedis.prototype.trafficTypeExists = function (trafficType) {
|
|
190
|
+
var _this = this;
|
|
191
|
+
// If there is a number there should be > 0, otherwise the TT is considered as not existent.
|
|
192
|
+
return this.redis.get(this.keys.buildTrafficTypeKey(trafficType))
|
|
193
|
+
.then(function (ttCount) {
|
|
194
|
+
if (ttCount === null)
|
|
195
|
+
return false; // if entry doesn't exist, means that TT doesn't exist
|
|
196
|
+
ttCount = parseInt(ttCount, 10);
|
|
197
|
+
if (!isFiniteNumber(ttCount) || ttCount < 0) {
|
|
198
|
+
_this.log.info(LOG_PREFIX + "Could not validate traffic type existence of ".concat(trafficType, " due to data corruption of some sorts."));
|
|
199
|
+
return false;
|
|
200
|
+
}
|
|
201
|
+
return ttCount > 0;
|
|
202
|
+
})
|
|
203
|
+
.catch(function (e) {
|
|
204
|
+
_this.log.error(LOG_PREFIX + "Could not validate traffic type existence of ".concat(trafficType, " due to an error: ").concat(e, "."));
|
|
205
|
+
// If there is an error, bypass the validation so the event can get tracked.
|
|
206
|
+
return true;
|
|
207
|
+
});
|
|
208
|
+
};
|
|
209
|
+
// @TODO remove or implement. It is not being used.
|
|
210
|
+
DefinitionsCacheInRedis.prototype.clear = function () {
|
|
211
|
+
return Promise.resolve();
|
|
212
|
+
};
|
|
213
|
+
/**
|
|
214
|
+
* Fetches multiple definitions.
|
|
215
|
+
* Returned promise is rejected if redis operation fails.
|
|
216
|
+
*/
|
|
217
|
+
DefinitionsCacheInRedis.prototype.getMany = function (names) {
|
|
218
|
+
var _a;
|
|
219
|
+
var _this = this;
|
|
220
|
+
if (this.redisError) {
|
|
221
|
+
this.log.error(LOG_PREFIX + this.redisError);
|
|
222
|
+
return Promise.reject(this.redisError);
|
|
223
|
+
}
|
|
224
|
+
var keys = names.map(function (name) { return _this.keys.buildDefinitionKey(name); });
|
|
225
|
+
return (_a = this.redis).mget.apply(_a, keys).then(function (stringifiedDefinitions) {
|
|
226
|
+
var definitions = {};
|
|
227
|
+
names.forEach(function (name, idx) {
|
|
228
|
+
var definition = stringifiedDefinitions[idx];
|
|
229
|
+
definitions[name] = definition && JSON.parse(definition);
|
|
230
|
+
});
|
|
231
|
+
return Promise.resolve(definitions);
|
|
232
|
+
})
|
|
233
|
+
.catch(function (e) {
|
|
234
|
+
_this.log.error(LOG_PREFIX + "Could not grab feature flags due to an error: ".concat(e, "."));
|
|
235
|
+
return Promise.reject(e);
|
|
236
|
+
});
|
|
237
|
+
};
|
|
238
|
+
return DefinitionsCacheInRedis;
|
|
239
|
+
}(AbstractDefinitionsCacheAsync));
|
|
240
|
+
export { DefinitionsCacheInRedis };
|
|
@@ -16,7 +16,7 @@ var EventsCacheInRedis = /** @class */ (function () {
|
|
|
16
16
|
// We use boolean values to signal successful queueing
|
|
17
17
|
.then(function () { return true; })
|
|
18
18
|
.catch(function (err) {
|
|
19
|
-
_this.log.error(LOG_PREFIX
|
|
19
|
+
_this.log.error("".concat(LOG_PREFIX, "Error adding event to queue: ").concat(err, "."));
|
|
20
20
|
return false;
|
|
21
21
|
});
|
|
22
22
|
};
|
|
@@ -32,7 +32,7 @@ var ImpressionCountsCacheInRedis = /** @class */ (function (_super) {
|
|
|
32
32
|
}
|
|
33
33
|
})
|
|
34
34
|
.catch(function (err) {
|
|
35
|
-
_this.log.error(LOG_PREFIX
|
|
35
|
+
_this.log.error("".concat(LOG_PREFIX, "Error in impression counts pipeline: ").concat(err, "."));
|
|
36
36
|
return false;
|
|
37
37
|
});
|
|
38
38
|
};
|
|
@@ -55,17 +55,17 @@ var ImpressionCountsCacheInRedis = /** @class */ (function (_super) {
|
|
|
55
55
|
forOwn(counts, function (count, key) {
|
|
56
56
|
var nameAndTime = key.split('::');
|
|
57
57
|
if (nameAndTime.length !== 2) {
|
|
58
|
-
_this.log.error(LOG_PREFIX
|
|
58
|
+
_this.log.error("".concat(LOG_PREFIX, "Error spliting key ").concat(key));
|
|
59
59
|
return;
|
|
60
60
|
}
|
|
61
61
|
var timeFrame = parseInt(nameAndTime[1]);
|
|
62
62
|
if (isNaN(timeFrame)) {
|
|
63
|
-
_this.log.error(LOG_PREFIX
|
|
63
|
+
_this.log.error("".concat(LOG_PREFIX, "Error parsing time frame ").concat(nameAndTime[1]));
|
|
64
64
|
return;
|
|
65
65
|
}
|
|
66
66
|
var rawCount = parseInt(count);
|
|
67
67
|
if (isNaN(rawCount)) {
|
|
68
|
-
_this.log.error(LOG_PREFIX
|
|
68
|
+
_this.log.error("".concat(LOG_PREFIX, "Error parsing raw count ").concat(count));
|
|
69
69
|
return;
|
|
70
70
|
}
|
|
71
71
|
pf.push({
|
|
@@ -31,7 +31,7 @@ var RBSegmentsCacheInRedis = /** @class */ (function () {
|
|
|
31
31
|
return _this.redis.set(key, stringifiedNewRBSegment).then(function () { return true; });
|
|
32
32
|
})),
|
|
33
33
|
Promise.all(toRemove.map(function (toRemove) {
|
|
34
|
-
var key = _this.keys.buildRBSegmentKey(toRemove
|
|
34
|
+
var key = _this.keys.buildRBSegmentKey(toRemove);
|
|
35
35
|
return _this.redis.del(key).then(function (status) { return status === 1; });
|
|
36
36
|
}))
|
|
37
37
|
]).then(function (_a) {
|
|
@@ -58,9 +58,9 @@ var RedisAdapter = /** @class */ (function () {
|
|
|
58
58
|
var _this = this;
|
|
59
59
|
this.client.once('ready', function () {
|
|
60
60
|
var commandsCount = _this._notReadyCommandsQueue ? _this._notReadyCommandsQueue.length : 0;
|
|
61
|
-
_this.log.info(LOG_PREFIX +
|
|
61
|
+
_this.log.info(LOG_PREFIX + "Redis connection established. Queued commands: ".concat(commandsCount, "."));
|
|
62
62
|
_this._notReadyCommandsQueue && _this._notReadyCommandsQueue.forEach(function (queued) {
|
|
63
|
-
_this.log.info(LOG_PREFIX +
|
|
63
|
+
_this.log.info(LOG_PREFIX + "Executing queued ".concat(queued.name, " command."));
|
|
64
64
|
queued.command().then(queued.resolve).catch(queued.reject);
|
|
65
65
|
});
|
|
66
66
|
// After the SDK is ready for the first time we'll stop queueing commands. This is just so we can keep handling BUR for them.
|
|
@@ -82,7 +82,7 @@ var RedisAdapter = /** @class */ (function () {
|
|
|
82
82
|
params[_i] = arguments[_i];
|
|
83
83
|
}
|
|
84
84
|
function commandWrapper() {
|
|
85
|
-
instance.log.debug(LOG_PREFIX
|
|
85
|
+
instance.log.debug("".concat(LOG_PREFIX, "Executing ").concat(methodName, "."));
|
|
86
86
|
var result = originalMethod.apply(bindTarget, params);
|
|
87
87
|
if (thenable(result)) {
|
|
88
88
|
// For handling pending commands on disconnect, add to the set and remove once finished.
|
|
@@ -94,7 +94,7 @@ var RedisAdapter = /** @class */ (function () {
|
|
|
94
94
|
// Both success and error remove from queue.
|
|
95
95
|
result.then(cleanUpRunningCommandsCb, cleanUpRunningCommandsCb);
|
|
96
96
|
return timeout(instance._options.operationTimeout, result).catch(function (err) {
|
|
97
|
-
instance.log.error(""
|
|
97
|
+
instance.log.error("".concat(LOG_PREFIX).concat(methodName, " operation threw an error or exceeded configured timeout of ").concat(instance._options.operationTimeout, "ms. Message: ").concat(err));
|
|
98
98
|
// Handling is not the adapter responsibility.
|
|
99
99
|
throw err;
|
|
100
100
|
});
|
|
@@ -132,7 +132,7 @@ var RedisAdapter = /** @class */ (function () {
|
|
|
132
132
|
}
|
|
133
133
|
var res = originalFn.apply(instance.client, args);
|
|
134
134
|
var originalExec = res.exec;
|
|
135
|
-
res.exec = wrapCommand(originalExec, methodName
|
|
135
|
+
res.exec = wrapCommand(originalExec, "".concat(methodName, ".exec"), res);
|
|
136
136
|
return res;
|
|
137
137
|
};
|
|
138
138
|
});
|
|
@@ -147,14 +147,14 @@ var RedisAdapter = /** @class */ (function () {
|
|
|
147
147
|
}
|
|
148
148
|
setTimeout(function deferredDisconnect() {
|
|
149
149
|
if (instance._runningCommands.size > 0) {
|
|
150
|
-
instance.log.info(LOG_PREFIX +
|
|
150
|
+
instance.log.info(LOG_PREFIX + "Attempting to disconnect but there are ".concat(instance._runningCommands.size, " commands still waiting for resolution. Defering disconnection until those finish."));
|
|
151
151
|
Promise.all(setToArray(instance._runningCommands))
|
|
152
152
|
.then(function () {
|
|
153
153
|
instance.log.debug(LOG_PREFIX + 'Pending commands finished successfully, disconnecting.');
|
|
154
154
|
originalMethod.apply(instance.client, params);
|
|
155
155
|
})
|
|
156
156
|
.catch(function (e) {
|
|
157
|
-
instance.log.warn(LOG_PREFIX +
|
|
157
|
+
instance.log.warn(LOG_PREFIX + "Pending commands finished with error: ".concat(e, ". Proceeding with disconnection."));
|
|
158
158
|
originalMethod.apply(instance.client, params);
|
|
159
159
|
});
|
|
160
160
|
}
|
|
@@ -42,17 +42,17 @@ var TelemetryCacheInRedis = /** @class */ (function () {
|
|
|
42
42
|
Object.keys(latencies).forEach(function (field) {
|
|
43
43
|
var parsedField = parseLatencyField(field);
|
|
44
44
|
if (isString(parsedField)) {
|
|
45
|
-
_this.log.error("Ignoring invalid latency field: "
|
|
45
|
+
_this.log.error("Ignoring invalid latency field: ".concat(field, ": ").concat(parsedField));
|
|
46
46
|
return;
|
|
47
47
|
}
|
|
48
48
|
var count = parseInt(latencies[field]);
|
|
49
49
|
if (isNaNNumber(count)) {
|
|
50
|
-
_this.log.error("Ignoring latency with invalid count: "
|
|
50
|
+
_this.log.error("Ignoring latency with invalid count: ".concat(latencies[field]));
|
|
51
51
|
return;
|
|
52
52
|
}
|
|
53
53
|
var metadata = parsedField[0], method = parsedField[1], bucket = parsedField[2];
|
|
54
54
|
if (bucket >= MAX_LATENCY_BUCKET_COUNT) {
|
|
55
|
-
_this.log.error("Ignoring latency with invalid bucket: "
|
|
55
|
+
_this.log.error("Ignoring latency with invalid bucket: ".concat(bucket));
|
|
56
56
|
return;
|
|
57
57
|
}
|
|
58
58
|
var methodLatencies = result.get(metadata) || {};
|
|
@@ -74,12 +74,12 @@ var TelemetryCacheInRedis = /** @class */ (function () {
|
|
|
74
74
|
Object.keys(exceptions).forEach(function (field) {
|
|
75
75
|
var parsedField = parseExceptionField(field);
|
|
76
76
|
if (isString(parsedField)) {
|
|
77
|
-
_this.log.error("Ignoring invalid exception field: "
|
|
77
|
+
_this.log.error("Ignoring invalid exception field: ".concat(field, ": ").concat(parsedField));
|
|
78
78
|
return;
|
|
79
79
|
}
|
|
80
80
|
var count = parseInt(exceptions[field]);
|
|
81
81
|
if (isNaNNumber(count)) {
|
|
82
|
-
_this.log.error("Ignoring exception with invalid count: "
|
|
82
|
+
_this.log.error("Ignoring exception with invalid count: ".concat(exceptions[field]));
|
|
83
83
|
return;
|
|
84
84
|
}
|
|
85
85
|
var metadata = parsedField[0], method = parsedField[1];
|
|
@@ -101,7 +101,7 @@ var TelemetryCacheInRedis = /** @class */ (function () {
|
|
|
101
101
|
Object.keys(configs).forEach(function (field) {
|
|
102
102
|
var parsedField = parseMetadata(field);
|
|
103
103
|
if (isString(parsedField)) {
|
|
104
|
-
_this.log.error("Ignoring invalid config field: "
|
|
104
|
+
_this.log.error("Ignoring invalid config field: ".concat(field, ": ").concat(parsedField));
|
|
105
105
|
return;
|
|
106
106
|
}
|
|
107
107
|
var metadata = parsedField[0];
|
|
@@ -110,7 +110,7 @@ var TelemetryCacheInRedis = /** @class */ (function () {
|
|
|
110
110
|
result.set(metadata, config);
|
|
111
111
|
}
|
|
112
112
|
catch (e) {
|
|
113
|
-
_this.log.error("Ignoring invalid config: "
|
|
113
|
+
_this.log.error("Ignoring invalid config: ".concat(configs[field]));
|
|
114
114
|
}
|
|
115
115
|
});
|
|
116
116
|
return _this.redis.del(_this.keys.initPrefix).then(function () { return result; });
|
|
@@ -38,7 +38,7 @@ var UniqueKeysCacheInRedis = /** @class */ (function (_super) {
|
|
|
38
38
|
}
|
|
39
39
|
})
|
|
40
40
|
.catch(function (err) {
|
|
41
|
-
_this.log.error(LOG_PREFIX
|
|
41
|
+
_this.log.error("".concat(LOG_PREFIX, "Error in uniqueKeys pipeline: ").concat(err, "."));
|
|
42
42
|
return false;
|
|
43
43
|
});
|
|
44
44
|
};
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { validatePrefix } from '../KeyBuilder';
|
|
2
2
|
import { KeyBuilderSS } from '../KeyBuilderSS';
|
|
3
|
-
import {
|
|
3
|
+
import { DefinitionsCacheInRedis } from './DefinitionsCacheInRedis';
|
|
4
4
|
import { SegmentsCacheInRedis } from './SegmentsCacheInRedis';
|
|
5
5
|
import { ImpressionsCacheInRedis } from './ImpressionsCacheInRedis';
|
|
6
6
|
import { EventsCacheInRedis } from './EventsCacheInRedis';
|
|
@@ -45,7 +45,7 @@ export function InRedisStorage(options) {
|
|
|
45
45
|
telemetry.recordConfig();
|
|
46
46
|
});
|
|
47
47
|
return {
|
|
48
|
-
|
|
48
|
+
definitions: new DefinitionsCacheInRedis(log, keys, redisClient, settings.sync.__splitFiltersValidation),
|
|
49
49
|
rbSegments: new RBSegmentsCacheInRedis(log, keys, redisClient),
|
|
50
50
|
segments: new SegmentsCacheInRedis(log, keys, redisClient),
|
|
51
51
|
impressions: new ImpressionsCacheInRedis(log, keys.buildImpressionsKey(), redisClient, metadata),
|