lib/defaultCommandHandler.js
function (aggregateId, callback) {
    if (!aggregateId || !_.isString(aggregateId)) {
      var err = new Error('Please pass a valid aggregateId!');
      debug(err);
      throw err;
    }
    if (!callback || !_.isFunction(callback)) {
      var err = new Error('Please pass a valid callback!');
      debug(err);
      throw err;
    }

    var self = this;

    this.aggregateLock.getAll(aggregateId, function (err, workerIds) {
      if (err) {
        return callback(err);
      }

      if (workerIds.length === 1 && workerIds[0] === self.id) {
        return callback(null);
      }

      var err = new ConcurrencyError('Aggregate is locked by an other command handler!');
      debug(err);
      callback(err);
    });
  }
function (aggregateId, callback) {
    if (!aggregateId || !_.isString(aggregateId)) {
      var err = new Error('Please pass a valid aggregateId!');
      debug(err);
      throw err;
    }
    if (!callback || !_.isFunction(callback)) {
      var err = new Error('Please pass a valid callback!');
      debug(err);
      throw err;
    }

    var self = this;

    this.aggregateLock.getAll(aggregateId, function (err, workerIds) {
      if (err) {
        return callback(err);
      }

      if (workerIds.length === 1 && workerIds[0] === self.id) {
        return callback(null);
      }

      var err = new ConcurrencyError('Aggregate is locked by an other command handler!');
      debug(err);
      callback(err);
    });
  }
function ( aggregateId , callback ) { if ( ! aggregateId || ! _ . isString ( aggregateId ) ) { var err = new Error ( 'Please pass a valid aggregateId!' ) ; debug ( err ) ; throw err ; } if ( ! callback || ! _ . isFunction ( callback ) ) { var err = new Error ( 'Please pass a valid callback!' ) ; debug ( err ) ; throw err ; } var self = this ; this . aggregateLock . getAll ( aggregateId , function ( err , workerIds ) { if ( err ) { return callback ( err ) ; } if ( workerIds . length === 1 && workerIds [ 0 ] === self . id ) { return callback ( null ) ; } var err = new ConcurrencyError ( 'Aggregate is locked by an other command handler!' ) ; debug ( err ) ; callback ( err ) ; } ) ; }
Checks if the aggregate lock is ok.
@param {String}   aggregateId The passed aggregateId.
@param {Function} callback    The function, that will be called when this action is completed.
`function(err){}`
Checks if the aggregate lock is ok .