sqs-producer
Advanced tools
Comparing version 1.3.1 to 1.3.2
@@ -0,10 +1,28 @@ | ||
'use strict'; | ||
var AWS = require('aws-sdk'); | ||
var selectn = require('selectn'); | ||
var requiredOptions = [ | ||
'queueUrl' | ||
]; | ||
var BATCH_SIZE = 10; | ||
function validate(options) { | ||
requiredOptions.forEach(function (option) { | ||
if (!options[option]) { | ||
throw new Error('Missing SQS consumer option [' + option + '].'); | ||
} | ||
}); | ||
if (options.batchSize > 10 || options.batchSize < 1) { | ||
throw new Error('SQS batchSize option must be between 1 and 10.'); | ||
} | ||
} | ||
function Producer(options) { | ||
validate(options); | ||
this.queueUrl = options.queueUrl; | ||
this.batchSize = options.batchSize || 10; | ||
this.sqs = options.sqs || new AWS.SQS({ | ||
region: options.region | ||
region: options.region || 'eu-west-1' | ||
}); | ||
@@ -90,3 +108,3 @@ } | ||
var producer = this; | ||
var endIndex = startIndex + BATCH_SIZE; | ||
var endIndex = startIndex + this.batchSize; | ||
var batch = messages.slice(startIndex, endIndex); | ||
@@ -136,3 +154,3 @@ var params = { | ||
var size = selectn('Attributes.ApproximateNumberOfMessages', result); | ||
cb(null, parseInt(size)); | ||
cb(null, parseInt(size, 10)); | ||
}); | ||
@@ -139,0 +157,0 @@ }; |
{ | ||
"name": "sqs-producer", | ||
"version": "1.3.1", | ||
"version": "1.3.2", | ||
"description": "Enqueues messages onto a given SQS queue", | ||
@@ -5,0 +5,0 @@ "main": "index.js", |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
74821
199