- Performance improvement of the RuleEngine

-fix some spelling errors in the log texts
This commit is contained in:
Joe
2019-01-14 08:04:41 -06:00
parent ea1884f819
commit febcdcb105

View File

@@ -18,7 +18,7 @@ const logger = winston.createLogger({
exports.RuleEngine = class RuleEngine {
constructor(ruleSetFiles) {
logger.log("info", "Instanciated RulesEngine - RuleSetFiles: " + ruleSetFiles);
logger.log("info", "Instantiated RulesEngine - RuleSetFiles: " + ruleSetFiles);
this.ruleSet = {};
if (ruleSetFiles === "*") {
fs.readdirSync("./rules/").forEach(file => {
@@ -39,7 +39,7 @@ exports.RuleEngine = class RuleEngine {
} else {
logger.log("info", "Loading rule set file " + ruleSetFiles);
this.ruleSet = JSON.parse(fs.readFileSync('./rules/' + ruleSetFiles + '.rule.json', 'utf8'));
logger.log("info", "Adding Ruleset " + Object.keys(this.ruleSet)[0]);
logger.log("info", "Adding rule set " + Object.keys(this.ruleSet)[0]);
}
}
processData(inputLine) {
@@ -53,7 +53,9 @@ exports.RuleEngine = class RuleEngine {
processLogicAnd(allWhiteFilterRules, inputData) {
let retVal = true;
logger.log("debug", "Logic AND - start");
for (let i = 0; i < allWhiteFilterRules.length; i++) {
// if one condition is false the other one doens't need checking anymore,
// therefore including the retVal in the check condition of the below for loop
for (let i = 0; (i < allWhiteFilterRules.length && retVal); i++) {
let theWhiteFilterRule = allWhiteFilterRules[i];
logger.log("debug", " Logic AND - whiteFilterRule: " + JSON.stringify(theWhiteFilterRule));
if (theWhiteFilterRule.Logic === "-") {