Returns next command in the queue
@param {String} aggId The passed aggregate id.
@returns {Object}
513073
function (aggId) {
    if (!aggId || !_.isString(aggId)) {
      var err = new Error('Please pass a valid aggregate id!');
      debug(err);
      throw err;
    }

    if (this.queue[aggId] && this.queue[aggId].length > 0) {
      var nextCmd = this.queue[aggId][0];
      return nextCmd;
    }

    return null;
  }
768682
def _aggregate(self, instanceId, container, value, subKey = None):
    """"""

    # Get the aggregator.
    if instanceId not in self._aggregators:
      self._aggregators[instanceId] = _Stats.getAggregator(instanceId, self.__name)
    aggregator = self._aggregators[instanceId]

    # If we are aggregating, get the old value.
    if aggregator:
      oldValue = container.get(self.__name)
      if subKey:
        oldValue = oldValue[subKey]
        aggregator[0].update(aggregator[1], oldValue, value, subKey)
      else:
        aggregator[0].update(aggregator[1], oldValue, value)
882960
function getNextJob(){
  let job = null;

  while(!job && queue.size() > 0){
    let id = queue.pop().id;
    job = map[id];
  }

  return (!!job)?job:null;
}
871158
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;
    }

    this.aggregateLock.resolve(aggregateId, callback);
  }
214257
public function load(AggregateId $aggregateId) : AggregateRoot
    {
        return $this->getProperRepository($aggregateId->aggregateClass())->load($aggregateId);
    }
409258
def get_cli_event_returns(
            self,
            jid,
            minions,
            timeout=None,
            tgt='*',
            tgt_type='glob',
            verbose=False,
            progress=False,
            show_timeout=False,
            show_jid=False,
            **kwargs):
        '''
        
        '''
        log.trace('func get_cli_event_returns()')

        if verbose:
            msg = 'Executing job with jid {0}'.format(jid)
            print(msg)
            print('-' * len(msg) + '\n')
        elif show_jid:
            print('jid: {0}'.format(jid))

        # lazy load the connected minions
        connected_minions = None
        return_count = 0

        for ret in self.get_iter_returns(jid,
                                         minions,
                                         timeout=timeout,
                                         tgt=tgt,
                                         tgt_type=tgt_type,
                                         # (gtmanfred) expect_minions is popped here incase it is passed from a client
                                         # call. If this is not popped, then it would be passed twice to
                                         # get_iter_returns.
                                         expect_minions=(kwargs.pop('expect_minions', False) or verbose or show_timeout),
                                         **kwargs
                                         ):
            log.debug('return event: %s', ret)
            return_count = return_count + 1
            if progress:
                for id_, min_ret in six.iteritems(ret):
                    if not min_ret.get('failed') is True:
                        yield {'minion_count': len(minions), 'return_count': return_count}
            # replace the return structure for missing minions
            for id_, min_ret in six.iteritems(ret):
                if min_ret.get('failed') is True:
                    if connected_minions is None:
                        connected_minions = salt.utils.minions.CkMinions(self.opts).connected_ids()
                    if self.opts['minion_data_cache'] \
                            and salt.cache.factory(self.opts).contains('minions/{0}'.format(id_), 'data') \
                            and connected_minions \
                            and id_ not in connected_minions:

                        yield {
                            id_: {
                                'out': 'no_return',
                                'ret': 'Minion did not return. [Not connected]',
                                'retcode': salt.defaults.exitcodes.EX_GENERIC
                            }
                        }
                    else:
                        # don't report syndics as unresponsive minions
                        if not os.path.exists(os.path.join(self.opts['syndic_dir'], id_)):
                            yield {
                                id_: {
                                    'out': 'no_return',
                                    'ret': 'Minion did not return. [No response]'
                                    '\nThe minions may not have all finished running and any '
                                    'remaining minions will return upon completion. To look '
                                    'up the return data for this job later, run the following '
                                    'command:\n\n'
                                    'salt-run jobs.lookup_jid {0}'.format(jid),
                                    'retcode': salt.defaults.exitcodes.EX_GENERIC
                                }
                            }
                else:
                    yield {id_: min_ret}

        self._clean_up_subscriptions(jid)
1182215
function( origEvent ) {
            var next = steps.indexOf( activeStep ) + 1;
            next = next < steps.length ? steps[ next ] : steps[ 0 ];

            return goto( next, undefined, "next", origEvent );
        }
1080816
function next(...args) {
		// if the next function has been defined
		if (typeof utils.queue[utils.i + 1] !== 'undefined') {
			args.unshift(next);
			utils.i++;
			return utils.queue[utils.i](...args);
		}

		// if there are no more function, next will re-init fang group
		return init(args);
	}
1070152
def get_aggregate (config):
    """"""
    _urlqueue = urlqueue.UrlQueue(max_allowed_urls=config["maxnumurls"])
    _robots_txt = robots_txt.RobotsTxt(config["useragent"])
    plugin_manager = plugins.PluginManager(config)
    result_cache = results.ResultCache()
    return aggregator.Aggregate(config, _urlqueue, _robots_txt, plugin_manager,
        result_cache)
205423
function (req, res, next) {
      var id
      try { id = decodeURIComponent(req.url.substring(5)) }
      catch (_) { id = req.url.substring(5) }
      if(req.url.substring(0, 5) !== '/msg/' || !ref.isMsg(id)) return next()

      sbot.get(id, function (err, msg) {
        if(err) return next(err)
        send(res, {key: id, value: msg})
      })
    }
664401
function (aggregate, streams, clb) {
        agg = aggregate; // save it temporary so we can use it in the callback

        debug('');
        var err = self.verifyAggregate(aggregate, cmd);
        if (err) {
          return clb(err);
        }
        clb(null, aggregate, streams);
      }
371810
function(next) {
							if (!this.isValid) return next();
							fs.stat(path, function(err, stat) { // Try and read the stats - if we fail remove it from the list
								if (err) return next();
								next(null, stat);
							});
						}
188024
function (aggregate, streams, clb) {
        debug('handle command');
        self.letHandleCommandByAggregate(aggregate, cmd, function (err) { // err is a business rule error
          if (err) {
            return clb(err);
          }
          clb(null, aggregate, streams);
        });
      }
703396
def next_id(self):
        """"""
        msgid = self._id_template.format(self._next_id)
        self._next_id += 1
        return msgid
1147749
function (cmd, callback) {
    debug('called a custom command handler');
    console.log('Is your use case not solvable without a custom command handling? Sagas? Micro-Services?');

    var self = this;

    function _handle (aggId) {
      var concatenatedId = self.getConcatenatedId(aggId, cmd);

      var isFirst = !self.getNextCommandInQueue(concatenatedId);

      self.queueCommand(concatenatedId, cmd, callback);

      if (!isFirst) {
        return;
      }

      (function handleNext (aggregateId, c) {
        var concId = self.getConcatenatedId(aggregateId, c);
        var cmdEntry = self.getNextCommandInQueue(concId);
        if (cmdEntry) {
          if (cmdEntry.callback.length > 2) {
            self.cmdHndlFn(aggregateId, cmdEntry.command, self, function (err, evts, aggData, meta) {
              self.removeCommandFromQueue(concId, cmdEntry.command);
              handleNext(aggregateId, cmdEntry.command);
              cmdEntry.callback(err, evts, aggData, meta);
            });
            return;
          }
          self.cmdHndlFn(aggregateId, cmdEntry.command, self, function (err, evts) {
            self.removeCommandFromQueue(concId, cmdEntry.command);
            handleNext(aggregateId, cmdEntry.command);
            cmdEntry.callback(err, evts);
          });
        }
      })(aggId, cmd);
    }

    if (dotty.exists(cmd, this.definitions.command.aggregateId)) {
      return _handle(dotty.get(cmd, this.definitions.command.aggregateId));
    }

    debug('no aggregateId in command, so generate a new one');

    this.getNewAggregateId(cmd, function (err, id) {
      if (err) {
        debug(err);
        return callback(err);
      }

      return _handle(id);
    });
  }
988156
private synchronized TableBucket getNextBucketFromExistingBatch() {
        if (this.currentBatch != null) {
            TableBucket next = this.currentBatch.next();
            if (!this.currentBatch.hasNext()) {
                this.currentBatch = null;
            }

            return next;
        }

        return null;
    }
1236250
def gid(self):
        
        if not self._gid:
            if self.controller.config.daemon.group:
                self._gid = grp.getgrnam(self.config.daemon.group).gr_gid
            else:
                self._gid = os.getgid()
        return self._gid