lib/amqp/machine-factory.js
function() {
      this.emit('acquiring');
      const onAcquisitionError = (err) => {
        logger.debug('Resource acquisition failed with error', err);
        this.emit('failed', err);
        this.handle('failed');
      };
      const onAcquired = (o) => {
        this.item = o;
        this.waitInterval = 0;
        if (this.item.on) {
          this.disposeHandle = this.item.once(disposalEvent || 'close', (err) => {
            logger.info('Resource lost, releasing', err);
            this.emit('lost');
            this.transition('released');
          });
          this.item.once('error', (err) => {
            logger.info('Resource error', err);
            this.transition('failed');
          });
          this.item.on('drain', () => {
            this.emit('drain');
          });
        }
        this.transition('acquired');
      };
      const onException = (ex) => {
        logger.debug('Resource acquisition failed with exception', ex);
        this.emit('failed', ex);
        this.handle('failed');
      };
      factory()
        .then(onAcquired, onAcquisitionError)
        .catch(onException);
    }
function() {
      this.emit('acquiring');
      const onAcquisitionError = (err) => {
        logger.debug('Resource acquisition failed with error', err);
        this.emit('failed', err);
        this.handle('failed');
      };
      const onAcquired = (o) => {
        this.item = o;
        this.waitInterval = 0;
        if (this.item.on) {
          this.disposeHandle = this.item.once(disposalEvent || 'close', (err) => {
            logger.info('Resource lost, releasing', err);
            this.emit('lost');
            this.transition('released');
          });
          this.item.once('error', (err) => {
            logger.info('Resource error', err);
            this.transition('failed');
          });
          this.item.on('drain', () => {
            this.emit('drain');
          });
        }
        this.transition('acquired');
      };
      const onException = (ex) => {
        logger.debug('Resource acquisition failed with exception', ex);
        this.emit('failed', ex);
        this.handle('failed');
      };
      factory()
        .then(onAcquired, onAcquisitionError)
        .catch(onException);
    }
function ( ) { this . emit ( 'acquiring' ) ; const onAcquisitionError = ( err ) => { logger . debug ( 'Resource acquisition failed with error' , err ) ; this . emit ( 'failed' , err ) ; this . handle ( 'failed' ) ; } ; const onAcquired = ( o ) => { this . item = o ; this . waitInterval = 0 ; if ( this . item . on ) { this . disposeHandle = this . item . once ( disposalEvent || 'close' , ( err ) => { logger . info ( 'Resource lost, releasing' , err ) ; this . emit ( 'lost' ) ; this . transition ( 'released' ) ; } ) ; this . item . once ( 'error' , ( err ) => { logger . info ( 'Resource error' , err ) ; this . transition ( 'failed' ) ; } ) ; this . item . on ( 'drain' , ( ) => { this . emit ( 'drain' ) ; } ) ; } this . transition ( 'acquired' ) ; } ; const onException = ( ex ) => { logger . debug ( 'Resource acquisition failed with exception' , ex ) ; this . emit ( 'failed' , ex ) ; this . handle ( 'failed' ) ; } ; factory ( ) . then ( onAcquired , onAcquisitionError ) . catch ( onException ) ; }
Does the work in acquiring a resource and sets up events for state transitions.

@private
@memberOf PromiseMachine.prototype
Does the work in acquiring a resource and sets up events for state transitions .