<commit_before>"use strict";

exports.enable = enable;
exports.disable = disable;
exports.shoutStreaming = shoutStreaming;
exports.getPlugins = getPlugins;

var util = require("util"),
    flic = require("flic"),
    async = require("async");

var FlicNode = flic.node,
    nodeName = "master",
    plugins = {};

var masterNode = new FlicNode(nodeName, function (err) {
    if (!err) {
        util.log("Argo streaming node online");
    } else {
        util.log(err);
    }
});

masterNode.on("argo.register", function (pluginName, done) {
    plugins[pluginName] = true;
    util.log("Argo plugin registered", pluginName);
    done();
});

masterNode.on("argo.unregister", function (pluginName, done) {
    delete plugins[pluginName];
    util.log("Argo plugin unregistered", pluginName);
    done();
});

masterNode.on("error", function (err) {
    util.log(err);
});

function enable(name) {
    masterNode.tell(name + ":argo.enable");
}

function disable(name) {
    masterNode.tell(name + ":argo.disable");
}

function shoutStreaming(data) {
    masterNode.shout("argo.streaming", data);
}

function getPlugins(callback) {
    var pluginNames = Object.keys(plugins),
        tellSeries = {};

    pluginNames.forEach(function (name) {
        tellSeries[name] = function (done) {
            var event = name + ":argo.status";
            masterNode.tell(event, name, function (err, status) {
                if (!err) {
                    done(null, status);
                }
            });
        };
    });

    async.series(tellSeries, function (err, res) {
        if (!err) {
            callback(err, res);
        }
    });
}<commit_msg>Replace enable/disable with engagePlugins.<commit_after>"use strict";

exports.shoutStreaming = shoutStreaming;
exports.getPlugins = getPlugins;
exports.engagePlugins = engagePlugins;

var util = require("util"),
    flic = require("flic"),
    async = require("async");

var FlicNode = flic.node,
    nodeName = "master",
    plugins = {};

var masterNode = new FlicNode(nodeName, function (err) {
    if (!err) {
        util.log("Argo streaming node online");
    } else {
        util.log(err);
    }
});

masterNode.on("argo.register", function (pluginName, done) {
    plugins[pluginName] = true;
    util.log("Argo plugin registered", pluginName);
    done();
});

masterNode.on("argo.unregister", function (pluginName, done) {
    delete plugins[pluginName];
    util.log("Argo plugin unregistered", pluginName);
    done();
});

masterNode.on("error", function (err) {
    util.log(err);
});

function enable(name, callback) {
    var event = name + ":argo.enable";

    masterNode.tell(event, name, function (err) {
        if (!err) {
            callback();
        }
    });
}

function disable(name, callback) {
    var event = name + ":argo.disable";

    masterNode.tell(event, name, function (err) {
        if (!err) {
            callback();
        }
    });
}

function shoutStreaming(data) {
    masterNode.shout("argo.streaming", data);
}

function getPlugins(callback) {
    var pluginNames = Object.keys(plugins),
        tellSeries = {};

    pluginNames.forEach(function (name) {
        tellSeries[name] = function (done) {
            var event = name + ":argo.status";
            masterNode.tell(event, name, function (err, status) {
                if (!err) {
                    done(null, status);
                }
            });
        };
    });

    async.series(tellSeries, function (err, res) {
        if (!err) {
            callback(err, res);
        }
    });
}

function engagePlugins(plugs) {
    var pluginNames = Object.keys(plugs),
        tellSeries = {};

    pluginNames.forEach(function (name) {
        tellSeries[name] = function (done) {
            if (plugs[name]) {
                enable(name, done);
            } else {
                disable(name, done);
            }
        };
    });

    async.series(tellSeries);
}
{'fraction_non_alphanumeric': 0.14955640050697086, 'fraction_numerical': 0.0, 'mean_word_length': 2.470536499560246, 'pattern_counts': {'":': 6, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4894126', 'n_tokens_mistral': 1209, 'n_tokens_neox': 1180, 'n_words': 254}