Last active
August 24, 2017 23:24
-
-
Save alexcusack/8bb684beb46af55ea45c2a44db48cb10 to your computer and use it in GitHub Desktop.
Revisions
-
alexcusack revised this gist
Aug 24, 2017 . 1 changed file with 1 addition and 1 deletion.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -10,7 +10,7 @@ import {range} from 'lodash'; import * as P from 'bluebird'; function enqueueParallelExecutions(buckets, queueService) { const enqueuedRequests = range(buckets).map((bucket) => { return queueService.enqueue('payment-processor', {bucket, buckets}); }); return P.all(enqueuedRequests); -
alexcusack revised this gist
Aug 24, 2017 . 1 changed file with 3 additions and 0 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -6,6 +6,9 @@ * @returns {Promise(<Array>)} Array of queue receipts */ import {range} from 'lodash'; import * as P from 'bluebird'; function enqueueParallelExecutions(buckets, queueService) { const enqueuedRequests = _.range(buckets).map((bucket) => { return queueService.enqueue('payment-processor', {bucket, buckets}); -
alexcusack revised this gist
Aug 24, 2017 . 1 changed file with 1 addition and 8 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -8,14 +8,7 @@ function enqueueParallelExecutions(buckets, queueService) { const enqueuedRequests = _.range(buckets).map((bucket) => { return queueService.enqueue('payment-processor', {bucket, buckets}); }); return P.all(enqueuedRequests); } -
alexcusack created this gist
Aug 24, 2017 .There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,21 @@ /** * A not-exactly-how-we-did-this-but-something-similar-implementation * Enqueues a payment-processor execution for 0 - (buckets - 1) * @param {Int} buckets: the number of Payment Processor executions to enqueue * @param {Object} queue: Amazon SQS queue * @returns {Promise(<Array>)} Array of queue receipts */ function enqueueParallelExecutions(buckets, queueService) { const enqueuedRequests = _.range(buckets).map((bucket) => { const payload = {buckets: buckets, bucket: bucket}; console.log('enqueuing payload', payload, 'debug'); return queueService.enqueue('payment-processor', payload) .catch(function (e) { // catch and log errors for each enqueued job individually // since P.all() will reject with a single error if any reject console.log('enqueuing failed', payload, 'error'); }); }); return P.all(enqueuedRequests); }