<commit_before>// Copyright 2015, EMC, Inc.

'use strict';

module.exports = messengerFactory;

messengerFactory.$provide = 'Messenger';
messengerFactory.$inject = [
    'Constants',
    'Promise',
    'Assert',
    'Connection',
    'Message',
    'Subscription',
    '_',
    'Errors',
    'ErrorEvent',
    'Serializable',
    'shortid',
    'Timer',
    'Services.StatsD',
    '$injector'
];

function messengerFactory(
    Constants,
    Promise,
    assert,
    Connection,
    Message,
    Subscription,
    _,
    Errors,
    ErrorEvent,
    Serializable,
    shortid,
    Timer,
    statsd,
    injector
) {
    var queueOptions = {
        exclusive: true
    };

    var subscribeOptions = {
        exclusive: true
    };

   /**
     * validates data based on whether it is a serializable or not
     * @param  {Object|Serializable} data
     * @return {Promise}
     */
    function validate(data) {
        if (data instanceof Serializable) {
            return data.validate();
        } else {
            return Promise.resolve();
        }
    }

    /**
     * Generates a random queue name based on the name/routingKey that
     * the queue is going to be bound to.
     */
    function queueName(name, routingKey) {
        return '%s:%s:%s'.format(name, routingKey, shortid.generate());
    }

    function Messenger () {
        this.startupPriority = 1;
        this.initialConnection = false;
        this.subscriptions = {};
        this.timeout = 1000;
    }

    /**
     * Initializes an AMQP connection.
     *
     * @returns {Promise}
     */
    Messenger.prototype.start = function () {
        var self = this,
            configuration = injector.get('Services.Configuration'),
            uri = configuration.get('amqp', 'amqp://localhost');

        assert.ok(uri, 'uri');

        var options;

        if (typeof uri === 'string') {
            options = {
                url: uri
            };
        } else {
            options = uri;<commit_msg>Added default case for AMQP URL<commit_after>// Copyright 2015, EMC, Inc.

'use strict';

module.exports = messengerFactory;

messengerFactory.$provide = 'Messenger';
messengerFactory.$inject = [
    'Constants',
    'Promise',
    'Assert',
    'Connection',
    'Message',
    'Subscription',
    '_',
    'Errors',
    'ErrorEvent',
    'Serializable',
    'shortid',
    'Timer',
    'Services.StatsD',
    '$injector'
];

function messengerFactory(
    Constants,
    Promise,
    assert,
    Connection,
    Message,
    Subscription,
    _,
    Errors,
    ErrorEvent,
    Serializable,
    shortid,
    Timer,
    statsd,
    injector
) {
    var queueOptions = {
        exclusive: true
    };

    var subscribeOptions = {
        exclusive: true
    };

   /**
     * validates data based on whether it is a serializable or not
     * @param  {Object|Serializable} data
     * @return {Promise}
     */
    function validate(data) {
        if (data instanceof Serializable) {
            return data.validate();
        } else {
            return Promise.resolve();
        }
    }

    /**
     * Generates a random queue name based on the name/routingKey that
     * the queue is going to be bound to.
     */
    function queueName(name, routingKey) {
        return '%s:%s:%s'.format(name, routingKey, shortid.generate());
    }

    function Messenger () {
        this.startupPriority = 1;
        this.initialConnection = false;
        this.subscriptions = {};
        this.timeout = 1000;
    }

    /**
     * Initializes an AMQP connection.
     *
     * @returns {Promise}
     */
    Messenger.prototype.start = function () {
        var self = this,
            configuration = injector.get('Services.Configuration'),
            uri = configuration.get('amqp', 'amqp://localhost');

        assert.ok(uri, 'uri');

        var options;

        if (typeof uri === 'string') {
            options = {
                url: uri
            };
        } else if (Array.isArray(uri)) {
            options = uri;
        } else {
            console.log('Setting AMQP URL to localhost');
            options = {
                url: 'amqp://localhost'
            };
{'fraction_non_alphanumeric': 0.1212338593974175, 'fraction_numerical': 0.00430416068866571, 'mean_word_length': 1.876891334250344, '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': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '320285', 'n_tokens_mistral': 1235, 'n_tokens_neox': 1176, 'n_words': 293}