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

'use strict';

module.exports = taskProtocolFactory;

taskProtocolFactory.$provide = 'Protocol.Task';
taskProtocolFactory.$inject = [
    'Promise',
    'Assert',
    'Constants',
    'Errors',
    'Services.Messenger',
    '_',
    'Result'
];

function taskProtocolFactory (Promise, assert, Constants, Errors, messenger, _, Result) {
    function TaskProtocol() {
    }

    TaskProtocol.prototype.run = function (domain, data) {
        assert.string(domain);

        return messenger.publish(
            Constants.Protocol.Exchanges.Task.Name,
            domain + '.' + 'methods.run',
            data || {}
        );
    };

    TaskProtocol.prototype.subscribeRun = function(domain, callback) {
        assert.string(domain);
        assert.func(callback);

        return messenger.subscribe(
            Constants.Protocol.Exchanges.Task.Name,
            domain + '.' + 'methods.run',
            callback
        );
    };

    TaskProtocol.prototype.cancel = function (taskId, errName, errMessage) {
        assert.uuid(taskId);

        return messenger.publish(
            Constants.Protocol.Exchanges.Task.Name,
            'methods.cancel',
            { taskId: taskId, errName: errName, errMessage: errMessage }
        );
    };

    TaskProtocol.prototype.subscribeCancel = function(callback) {
        assert.func(callback);

        return messenger.subscribe(
            Constants.Protocol.Exchanges.Task.Name,
            'methods.cancel',
            function(data) {
                if (!data.errName) {
                    return callback(data);
                }
                // Re-create error sent over the wire
                if (Errors[data.errName]) {
                    callback(new Errors[data.errName](data.errMessage));
                } else {
                    callback(new Error(data.errMessage));
                }<commit_msg>Remove wrong parameter for function taskprotocol's cancel<commit_after>// Copyright 2015, EMC, Inc.

'use strict';

module.exports = taskProtocolFactory;

taskProtocolFactory.$provide = 'Protocol.Task';
taskProtocolFactory.$inject = [
    'Promise',
    'Assert',
    'Constants',
    'Errors',
    'Services.Messenger',
    '_',
    'Result'
];

function taskProtocolFactory (Promise, assert, Constants, Errors, messenger, _, Result) {
    function TaskProtocol() {
    }

    TaskProtocol.prototype.run = function (domain, data) {
        assert.string(domain);

        return messenger.publish(
            Constants.Protocol.Exchanges.Task.Name,
            domain + '.' + 'methods.run',
            data || {}
        );
    };

    TaskProtocol.prototype.subscribeRun = function(domain, callback) {
        assert.string(domain);
        assert.func(callback);

        return messenger.subscribe(
            Constants.Protocol.Exchanges.Task.Name,
            domain + '.' + 'methods.run',
            callback
        );
    };

    TaskProtocol.prototype.cancel = function (taskId) {
        assert.uuid(taskId);

        return messenger.publish(
            Constants.Protocol.Exchanges.Task.Name,
            'methods.cancel',
            { taskId: taskId }
        );
    };

    TaskProtocol.prototype.subscribeCancel = function(callback) {
        assert.func(callback);

        return messenger.subscribe(
            Constants.Protocol.Exchanges.Task.Name,
            'methods.cancel',
            function(data) {
                if (!data.errName) {
                    return callback(data);
                }
                // Re-create error sent over the wire
                if (Errors[data.errName]) {
                    callback(new Errors[data.errName](data.errMessage));
                } else {
                    callback(new Error(data.errMessage));
                }
{'fraction_non_alphanumeric': 0.11621833376860799, 'fraction_numerical': 0.0020893183598850876, 'mean_word_length': 1.9037149355572403, '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': '2716963', 'n_tokens_mistral': 1034, 'n_tokens_neox': 971, 'n_words': 182}