app.js
function notify (doc) {
  // find queue, find worker...
  if (_.isArray(workers[doc.type]) && !_.isEmpty(workers[doc.type])) {
    var wkr = workers[doc.type].shift();
    // update doc as processing
    db.atomic('dequeue', 'id', doc._id, function (err, body) {
      if (err) {
        log.error(err);
        return wkr.send(ERROR, err);
      }

      var job = _.extend(doc.job, {
        id: doc._id,
        ok: true
      });
      wkr.send(SUCCESS, job);
    });
  }
}
function notify (doc) {
  // find queue, find worker...
  if (_.isArray(workers[doc.type]) && !_.isEmpty(workers[doc.type])) {
    var wkr = workers[doc.type].shift();
    // update doc as processing
    db.atomic('dequeue', 'id', doc._id, function (err, body) {
      if (err) {
        log.error(err);
        return wkr.send(ERROR, err);
      }

      var job = _.extend(doc.job, {
        id: doc._id,
        ok: true
      });
      wkr.send(SUCCESS, job);
    });
  }
}
function notify ( doc ) { // find queue, find worker... if ( _ . isArray ( workers [ doc . type ] ) && ! _ . isEmpty ( workers [ doc . type ] ) ) { var wkr = workers [ doc . type ] . shift ( ) ; // update doc as processing db . atomic ( 'dequeue' , 'id' , doc . _id , function ( err , body ) { if ( err ) { log . error ( err ) ; return wkr . send ( ERROR , err ) ; } var job = _ . extend ( doc . job , { id : doc . _id , ok : true } ) ; wkr . send ( SUCCESS , job ) ; } ) ; } }
if worker is listening - notify..
if worker is listening - notify ..