<commit_before>var MongoClient = require('mongodb').MongoClient;

class Mongo {
    constructor(url, logger) {
        this.driver = null;
        this.logger = logger;
        this.queue = [];
        this.performing = false;
        MongoClient.connect(url, (err, db) => {
            if(err) {
                this.logger.error('Mongo', 'Error connecting to MongoDB instance: ', err);
                return;
            }
            this.driver = db;
            this.logger.verbose('Mongo', `Connected: ${url}`);
            this._processQueue();
        });
    }

    isConnected() {
        return this.driver !== null;
    }

    perform(func) {
        this.queue.push(func);
        if(!this.performing && this.isConnected()) {
            this.performing = true;
            this._processQueue();
        }
    }

    _processQueue() {
        var func = this.queue.shift();
        if(!func) {
            this.performing = false;
            return;
        } else {
            try {
                func(this.driver, this._processQueue.bind(this));
            } catch(ex) {
                this.logger.error('Mongo', 'Error performing operation: ', ex);
                this.logger.error('Mongo', 'Resuming...');
                this._processQueue();
            }
        }
    }
}

module.exports = Mongo;<commit_msg>Prepare mongo manager implementation for removal<commit_after>// Marked to removal
var MongoClient = require('mongodb').MongoClient;

class Mongo {
    constructor(url, logger) {
        this.driver = null;
        this.logger = logger;
        this.queue = [];
        this.performing = false;
        MongoClient.connect(url, (err, db) => {
            if(err) {
                this.logger.error('Mongo', 'Error connecting to MongoDB instance: ', err);
                return;
            }
            this.driver = db;
            this.logger.verbose('Mongo', `Connected: ${url}`);
            this._processQueue();
        });
    }

    isConnected() {
        return this.driver !== null;
    }

    perform(func) {
        if(!this.driver) {
            this.queue.push(func);
        } else {
            func(this.driver, function() {});
        }
    }

    _processQueue() {
        this.queue.forEach((func) => {
            try {
                func(this.driver, function() {});
            } catch(ex) {
                this.logger.error('Mongo', 'Error performing operation: ', ex);
            }
        });
    }
}

module.exports = Mongo;
{'fraction_non_alphanumeric': 0.13942307692307693, 'fraction_numerical': 0.0, 'mean_word_length': 1.566289825282631, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 6, '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': '725687', 'n_tokens_mistral': 716, 'n_tokens_neox': 690, 'n_words': 129}