UNPKG

@splitsoftware/splitio-commons

Version:
20 lines (19 loc) 1.03 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.validateSplitExistence = void 0; var labels_1 = require("../labels"); var constants_1 = require("../../logger/constants"); /** * This is defined here and in this format mostly because of the logger and the fact that it's considered a validation at product level. * But it's not going to run on the input validation layer. In any case, the most compeling reason to use it as we do is to avoid going to Redis and get a split twice. */ function validateSplitExistence(log, readinessManager, splitName, labelOrSplitObj, method) { if (readinessManager.isReady()) { // Only if it's ready we validate this, otherwise it may just be that the SDK is not ready yet. if (labelOrSplitObj === labels_1.SPLIT_NOT_FOUND || labelOrSplitObj == null) { log.warn(constants_1.WARN_NOT_EXISTENT_SPLIT, [method, splitName]); return false; } } return true; } exports.validateSplitExistence = validateSplitExistence;