aws/SqsProvider.js
/**
		 * Reads all messages from queue (perhaps requiring multiple calls to the
		 * AWS SDK) and returns an array of messages (use with caution).
		 *
		 * @public
		 * @param {string} queueName - The name of the queue to read.
		 * @param {Function=} mapper - A function that can be used to map messages into something else.
		 * @param {Boolean=} synchronousDelete - If true, the promise won't resolve until new messages have been read *and deleted* from the queue.
		 * @param {Number=} maximumMessages - If positive, the maximum number of messages to read before stopping. This logic is approximate, you may receive a few more messages (up to ten more).
		 * @returns {Promise<Object[]>}
		 */
Reads all messages from queue (perhaps requiring multiple calls to the
AWS SDK) and returns an array of messages (use with caution).

@public
@param {string} queueName - The name of the queue to read.
@param {Function=} mapper - A function that can be used to map messages into something else.
@param {Boolean=} synchronousDelete - If true, the promise won't resolve until new messages have been read *and deleted* from the queue.
@param {Number=} maximumMessages - If positive, the maximum number of messages to read before stopping. This logic is approximate, you may receive a few more messages (up to ten more).
@returns {Promise}
Reads all messages from queue ( perhaps requiring multiple calls to the AWS SDK ) and returns an array of messages ( use with caution ) . @public @param { string } queueName - The name of the queue to read . @param { Function = } mapper - A function that can be used to map messages into something else . @param { Boolean = } synchronousDelete - If true the promise won ' t resolve until new messages have been read * and deleted * from the queue . @param { Number = } maximumMessages - If positive the maximum number of messages to read before stopping . This logic is approximate you may receive a few more messages ( up to ten more ) . @returns { Promise }
drain(queueName, mapper, synchronousDelete, maximumMessages) {
			return Promise.resolve()
				.then(() => {
					assert.argumentIsRequired(queueName, 'queueName', String);
					assert.argumentIsOptional(mapper, 'mapper', Function);
					assert.argumentIsOptional(synchronousDelete, 'synchronousDelete', Boolean);
					assert.argumentIsOptional(maximumMessages, 'maximumMessages', Number);
					const mapperToUse = mapper || (m => m);
					const batches = [ ];
					const batchSize = 10;
					let count = 0;
					const executeDrain = () => {
						return this.receive(queueName, 0, batchSize, synchronousDelete)
							.then((messages) => {
								batches.push(messages.map(mapperToUse));
								count = count + messages.length;
								if (messages.length === 0 || (is.positive(maximumMessages) && count >= maximumMessages)) {
									return batches;
								} else {
									return executeDrain();
								}
							});
					};
					return executeDrain()
						.then(() => {
							return array.flatten(batches);
						});
				});
		}
drain ( queueName , mapper , synchronousDelete , maximumMessages ) { return Promise . resolve ( ) . then ( ( ) => { assert . argumentIsRequired ( queueName , 'queueName' , String ) ; assert . argumentIsOptional ( mapper , 'mapper' , Function ) ; assert . argumentIsOptional ( synchronousDelete , 'synchronousDelete' , Boolean ) ; assert . argumentIsOptional ( maximumMessages , 'maximumMessages' , Number ) ; const mapperToUse = mapper || ( m => m ) ; const batches = [ ] ; const batchSize = 10 ; let count = 0 ; const executeDrain = ( ) => { return this . receive ( queueName , 0 , batchSize , synchronousDelete ) . then ( ( messages ) => { batches . push ( messages . map ( mapperToUse ) ) ; count = count + messages . length ; if ( messages . length === 0 || ( is . positive ( maximumMessages ) && count >= maximumMessages ) ) { return batches ; } else { return executeDrain ( ) ; } } ) ; } ; return executeDrain ( ) . then ( ( ) => { return array . flatten ( batches ) ; } ) ; } ) ; }
Reads all messages from queue (perhaps requiring multiple calls to the
 AWS SDK) and returns an array of messages (use with caution).
Reads all messages from queue ( perhaps requiring multiple calls to the AWS SDK ) and returns an array of messages ( use with caution ) .