<commit_before>'use strict';

/**
module.exports.redlock = {
  connection: 'redlock',
  prefix: 'redlock:',
  options: {
    driftFactor: 0.01,
    retryCount:  3,
    retryDelay:  200
  }
};
module.exports.connections = {
  redlock: {
    hosts: [{host: 'localhost', port: 6379}],
    password: '<PASSWORD>'
  }
}
**/

var Redlock = require('redlock');
var redis = require('redis');
var _redlock;

var redlock = {
  lock: function (resource) {
    arguments[0] = redlock.options.prefix + resource;
    return _redlock.lock.apply(_redlock, arguments);
  }
};

module.exports = function (done) {
  var connectionName = framework.config.redlock.connection;
  var connectionConfig = framework.config.connections[connectionName];
  if(!connectionConfig) {
    throw new Error('Undefined connection ' + connectionName);
  }
  redlock.options = {prefix: framework.config.redlock.prefix};

  var clients = _.map(connectionConfig.hosts, function (host) {
    var options = _.extend({}, connectionConfig);
    delete options.hosts;
    _.extend({port: 6379}, options, host);
    return redis.createClient(options);
  });

  _redlock = new Redlock(
      // you should have one client for each redis node
      // in your cluster
      clients,
      _.extend({
        // the expected clock drift; for more details
        // see http://redis.io/topics/distlock
        driftFactor: 0.01,
<commit_msg>fix error: Unhandled rejection LockError: Exceeded 3 attempts to lock the resource<commit_after>'use strict';

/**
module.exports.redlock = {
  connection: 'redlock',
  prefix: 'redlock:',
  options: {
    driftFactor: 0.01,
    retryCount:  3,
    retryDelay:  200
  }
};
module.exports.connections = {
  redlock: {
    hosts: [{host: 'localhost', port: 6379}],
    password: '<PASSWORD>'
  }
}
**/

var Redlock = require('redlock');
var redis = require('redis');
var _redlock;

var redlock = {
  lock: function (resource) {
    arguments[0] = redlock.options.prefix + resource;
    return _redlock.lock.apply(_redlock, arguments);
  }
};

module.exports = function (done) {
  var connectionName = framework.config.redlock.connection;
  var connectionConfig = framework.config.connections[connectionName];
  if(!connectionConfig) {
    throw new Error('Undefined connection ' + connectionName);
  }
  redlock.options = {prefix: framework.config.redlock.prefix};

  var clients = _.map(connectionConfig.hosts, function (host) {
    var options = _.extend({}, connectionConfig);
    delete options.hosts;
    options = _.extend({port: 6379}, options, host);
    return redis.createClient(options);
  });

  _redlock = new Redlock(
      // you should have one client for each redis node
      // in your cluster
      clients,
      _.extend({
        // the expected clock drift; for more details
        // see http://redis.io/topics/distlock
        driftFactor: 0.01,

{'fraction_non_alphanumeric': 0.13307719175689836, 'fraction_numerical': 0.013622074746769124, 'mean_word_length': 3.3525835866261398, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 5, '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': '28283', 'n_tokens_mistral': 907, 'n_tokens_neox': 879, 'n_words': 222}