Skip to content

Commit

Permalink
Merge pull request #3 from james075/master
Browse files Browse the repository at this point in the history
Make SQS Region config value optional.
  • Loading branch information
robinjmurphy committed May 18, 2015
2 parents eddcf65 + 2dba1a5 commit aa76830
Show file tree
Hide file tree
Showing 4 changed files with 7 additions and 16 deletions.
3 changes: 1 addition & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@ var Consumer = require('sqs-consumer');

var app = Consumer.create({
queueUrl: 'https://sqs.eu-west-1.amazonaws.com/account-id/queue-name',
region: 'eu-west-1',
handleMessage: function (message, done) {
// do some work with `message`
done();
Expand Down Expand Up @@ -46,7 +45,7 @@ Creates a new SQS consumer.
#### Options

* `queueUrl` - _String_ - The SQS queue URL
* `region` - _String_ - The AWS region
* `region` - _String_ - The AWS region (default `eu-west-1`)
* `handleMessage` - _Function_ - A function to be called whenever a message is receieved. Receives an SQS message object as its first argument and a function to call when the message has been handled as its second argument (i.e. `handleMessage(message, done)`).
* `batchSize` - _Number_ - The number of messages to request from SQS when polling (default `1`). This cannot be higher than the AWS limit of 10.
* `sqs` - _Object_ - An optional [AWS SQS](http://docs.aws.amazon.com/AWSJavaScriptSDK/latest/AWS/SQS.html) object to use if you need to configure the client manually
Expand Down
6 changes: 3 additions & 3 deletions index.js
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
'use strict';

var EventEmitter = require('events').EventEmitter;
var util = require('util');
var _ = require('lodash');
var async = require('async');
var AWS = require('aws-sdk');
var debug = require('debug')('sqs-consumer');
var requiredOptions = [
'queueUrl',
'region',
'handleMessage'
];

Expand Down Expand Up @@ -39,7 +39,7 @@ function Consumer(options) {
this.stopped = true;
this.batchSize = options.batchSize || 1;
this.sqs = options.sqs || new AWS.SQS({
region: options.region
region: options.region || 'eu-west-1'
});
}

Expand Down
3 changes: 1 addition & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,6 @@
"async": "^0.9.0",
"aws-sdk": "^2.0.23",
"codeclimate-test-reporter": "0.0.4",
"debug": "^2.1.0",
"lodash": "^2.4.1"
"debug": "^2.1.0"
}
}
11 changes: 2 additions & 9 deletions test/index.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
'use strict';

var Consumer = require('..');
var assert = require('assert');
var sinon = require('sinon');
Expand Down Expand Up @@ -37,15 +39,6 @@ describe('Consumer', function () {
});
});

it('requires an AWS region to be set', function () {
assert.throws(function () {
new Consumer({
queueUrl: 'some-queue-url',
handleMessage: handleMessage
});
});
});

it('requires a handleMessage function to be set', function () {
assert.throws(function () {
new Consumer({
Expand Down

0 comments on commit aa76830

Please sign in to comment.