<commit_before>/**
 * var connection = new Connection({ tag:             'kotoumi',
 *                                   hostName:        'localhost',
 *                                   port:            24224,
 *                                   receiveHostName: 'localhost',
 *                                   receivePort:     10030 });
 */

var EventEmitter = require('events').EventEmitter;
var extendedFluent = require('./fluent-logger');
var fluent = require('fluent-logger');
var Receiver = require('./receiver').Receiver;

var DEFAULT_FLUENT_TAG =
      Connection.DEFAULT_FLUENT_TAG =
        'kotoumi';
var DEFAULT_FLUENT_HOST_NAME =
      Connection.DEFAULT_FLUENT_HOST_NAME =
        'localhost';
var DEFAULT_FLUENT_PORT =
      Connection.DEFAULT_FLUENT_PORT =
        24224;
var DEFAULT_RECEIVE_HOST_NAME =
      Connection.DEFAULT_RECEIVE_HOST_NAME =
        'localhost';

var ERROR_GATEWAY_TIMEOUT =
      Connection.ERROR_GATEWAY_TIMEOUT =
        504;

function Connection(params) {
  this._params = params || {};
  this._init();
}

Connection.prototype = new EventEmitter();

Connection.prototype._init = function() {
  this._callbacks = {};
  this._initSender();
  this._initReceiver();
};

Connection.prototype._initSender = function(wait) {
  this._sender = this._params.sender;
  if (!this._params.sender) {
    var options = { host: this._params.hostName || DEFAULT_FLUENT_HOST_NAME,
                    port: this._params.port || DEFAULT_FLUENT_PORT,
                    reconnect: true };
    var sender = fluent.createFluentSender(this._params.tag || DEFAULT_FLUENT_TAG,
                                           options);
    this._sender = sender;
  }
};

Connection.prototype._initReceiver = function() {
  this.receiveHostName = this._params.receiveHostName || DEFAULT_RECEIVE_HOST_NAME;
  this.receivePort = this._params.receivePort;<commit_msg>Use overridden fluent-logger with the new API<commit_after>/**
 * var connection = new Connection({ tag:             'kotoumi',
 *                                   hostName:        'localhost',
 *                                   port:            24224,
 *                                   receiveHostName: 'localhost',
 *                                   receivePort:     10030 });
 */

var EventEmitter = require('events').EventEmitter;
var extendedFluent = require('./fluent-logger');
var fluent = require('fluent-logger');
var Receiver = require('./receiver').Receiver;

var DEFAULT_FLUENT_TAG =
      Connection.DEFAULT_FLUENT_TAG =
        'kotoumi';
var DEFAULT_FLUENT_HOST_NAME =
      Connection.DEFAULT_FLUENT_HOST_NAME =
        'localhost';
var DEFAULT_FLUENT_PORT =
      Connection.DEFAULT_FLUENT_PORT =
        24224;
var DEFAULT_FLUENT_MAX_RETRY_COUNT =
      Connection.DEFAULT_FLUENT_MAX_RETRY_COUNT =
        3;
var DEFAULT_FLUENT_RETRY_DELAY =
      Connection.DEFAULT_FLUENT_RETRY_DELAY =
        1000;
var DEFAULT_RECEIVE_HOST_NAME =
      Connection.DEFAULT_RECEIVE_HOST_NAME =
        'localhost';

var ERROR_GATEWAY_TIMEOUT =
      Connection.ERROR_GATEWAY_TIMEOUT =
        504;

function Connection(params) {
  this._params = params || {};
  this._init();
}

Connection.prototype = new EventEmitter();

Connection.prototype._init = function() {
  this._callbacks = {};
  this._initSender();
  this._initReceiver();
};

Connection.prototype._initSender = function(wait) {
  this._sender = this._params.sender;
  if (!this._params.sender) {
    var options = { host: this._params.hostName || DEFAULT_FLUENT_HOST_NAME,
                    port: this._params.port || DEFAULT_FLUENT_PORT,
                    maxRetryCount: this._params.maxRetryCount || DEFAULT_FLUENT_MAX_RETRY_COUNT,
                    retryDelay:    this._params.retryDelay || DEFAULT_FLUENT_RETRY_DELAY };
    var sender = fluent.createFluentSender(this._params.tag || DEFAULT_FLUENT_TAG,
                                           options);
    this._sender = sender;
  }
};

Connection.prototype._initReceiver = function() {
  this.receiveHostName = this._params.receiveHostName || DEFAULT_RECEIVE_HOST_NAME;
  this.receivePort = this._params.receivePort;
{'fraction_non_alphanumeric': 0.1017645636934977, 'fraction_numerical': 0.009910563210055595, 'mean_word_length': 2.4627615062761508, 'pattern_counts': {'":': 0, '<': 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': 12, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '7556526', 'n_tokens_mistral': 1213, 'n_tokens_neox': 1178, 'n_words': 197}