src/handlers.js
function onClose (ctx, err, val, cb) {
  // no callback no queue processing
  if (!_.isFunction(cb)) {
    ctx._heavy.stop();
    ctx._transport.close();
    if (err) {
      ctx.log.fatal(err);
      ctx.emit('error', err);
    }
    return;
  }

  // unsubscribe all active subscriptions
  ctx.removeAll();

  // wait until the client has flush all messages to nats
  ctx._transport.flush(() => {
    ctx._heavy.stop();
    // close NATS
    ctx._transport.close();

    if (err) {
      ctx.log.error(err);
      ctx.emit('error', err);
      if (_.isFunction(cb)) {
        cb(err);
      }
    } else {
      ctx.log.info(Constants.GRACEFULLY_SHUTDOWN);
      if (_.isFunction(cb)) {
        cb(null, val);
      }
    }
  });
}
function onClose (ctx, err, val, cb) {
  // no callback no queue processing
  if (!_.isFunction(cb)) {
    ctx._heavy.stop();
    ctx._transport.close();
    if (err) {
      ctx.log.fatal(err);
      ctx.emit('error', err);
    }
    return;
  }

  // unsubscribe all active subscriptions
  ctx.removeAll();

  // wait until the client has flush all messages to nats
  ctx._transport.flush(() => {
    ctx._heavy.stop();
    // close NATS
    ctx._transport.close();

    if (err) {
      ctx.log.error(err);
      ctx.emit('error', err);
      if (_.isFunction(cb)) {
        cb(err);
      }
    } else {
      ctx.log.info(Constants.GRACEFULLY_SHUTDOWN);
      if (_.isFunction(cb)) {
        cb(null, val);
      }
    }
  });
}
function onClose ( ctx , err , val , cb ) { // no callback no queue processing if ( ! _ . isFunction ( cb ) ) { ctx . _heavy . stop ( ) ; ctx . _transport . close ( ) ; if ( err ) { ctx . log . fatal ( err ) ; ctx . emit ( 'error' , err ) ; } return ; } // unsubscribe all active subscriptions ctx . removeAll ( ) ; // wait until the client has flush all messages to nats ctx . _transport . flush ( ( ) => { ctx . _heavy . stop ( ) ; // close NATS ctx . _transport . close ( ) ; if ( err ) { ctx . log . error ( err ) ; ctx . emit ( 'error' , err ) ; if ( _ . isFunction ( cb ) ) { cb ( err ) ; } } else { ctx . log . info ( Constants . GRACEFULLY_SHUTDOWN ) ; if ( _ . isFunction ( cb ) ) { cb ( null , val ) ; } } } ) ; }
Is called after all onClose extensions have been called
Is called after all onClose extensions have been called