src/middlewares/bulkhead.js
function callNext() {
			/* istanbul ignore next */
			if (queue.length == 0) return;

			/* istanbul ignore next */
			if (currentInFlight >= opts.concurrency) return;

			const item = queue.shift();

			currentInFlight++;
			handler(item.ctx)
				.then(res => {
					currentInFlight--;
					item.resolve(res);
					callNext();
				})
				.catch(err => {
					currentInFlight--;
					item.reject(err);
					callNext();
				});
		}
function callNext() {
			/* istanbul ignore next */
			if (queue.length == 0) return;

			/* istanbul ignore next */
			if (currentInFlight >= opts.concurrency) return;

			const item = queue.shift();

			currentInFlight++;
			handler(item.ctx)
				.then(res => {
					currentInFlight--;
					item.resolve(res);
					callNext();
				})
				.catch(err => {
					currentInFlight--;
					item.reject(err);
					callNext();
				});
		}
function callNext ( ) { /* istanbul ignore next */ if ( queue . length == 0 ) return ; /* istanbul ignore next */ if ( currentInFlight >= opts . concurrency ) return ; const item = queue . shift ( ) ; currentInFlight ++ ; handler ( item . ctx ) . then ( res => { currentInFlight -- ; item . resolve ( res ) ; callNext ( ) ; } ) . catch ( err => { currentInFlight -- ; item . reject ( err ) ; callNext ( ) ; } ) ; }
Call the next request from the queue
Call the next request from the queue