Comparing version 6.0.0-pre to 6.0.0
@@ -0,1 +1,15 @@ | ||
# 6.0.0 | ||
Now supporting AWS SQS. | ||
Handlers now receive their own copy of the job payload. | ||
We now debug-log the full job in case of error. When using SQS, this includes | ||
the receipt handle, which can be used to delete the job. | ||
Schedules now get their own queue. | ||
IronMQ still supported, but untested, unless you bring your own `iron.json`. | ||
# 5.0.0 | ||
@@ -2,0 +16,0 @@ |
@@ -446,7 +446,9 @@ 'use strict'; | ||
function runHandlers() { | ||
const body = parseBody(job.body); | ||
debug('Processing queued job %s:%s', self.name, jobID, bodyHash); | ||
const handlers = Array.from(self._handlers); | ||
const promises = handlers.map(handler => runJob(jobID, handler, [body], PROCESSING_TIMEOUT)); | ||
const promises = handlers.map(function(handler) { | ||
const body = parseBody(job.body); | ||
return runJob(jobID, handler, [body], PROCESSING_TIMEOUT); | ||
}); | ||
return Promise.all(promises); | ||
@@ -504,3 +506,4 @@ } | ||
domain.run(function() { | ||
debug('Error processing queued job %s:%s', self.name, jobID, error); | ||
const jobForLogging = Object.assign({}, job, { body: parseBody(job.body) }); | ||
debug('Error processing queued job in %s: %O', self.name, jobForLogging, error); | ||
}); | ||
@@ -507,0 +510,0 @@ } |
@@ -138,6 +138,4 @@ 'use strict'; | ||
sqsClient() { | ||
if (this._sqsClient) | ||
return this._sqsClient; | ||
else { | ||
const clientObject = new AWS.SQS({ | ||
if (!this._sqsClient) { | ||
this._sqsClient = new AWS.SQS({ | ||
accessKeyId: this.accessKeyId, | ||
@@ -148,4 +146,14 @@ secretAccessKey: this.secretAccessKey, | ||
}); | ||
} | ||
this._sqsClient = clientObject.getQueueUrl({ QueueName: this.queueName }).promise() | ||
return Promise.resolve() | ||
.then(() => this._setQueueURL()) | ||
.then(() => this._sqsClient); | ||
} | ||
_setQueueURL() { | ||
if (this.queueURL) | ||
return null; | ||
else { | ||
return this._sqsClient.getQueueUrl({ QueueName: this.queueName }).promise() | ||
.then(response => { | ||
@@ -155,6 +163,3 @@ const queueURL = response.QueueUrl; | ||
this.queueURL = queueURL; | ||
return clientObject; | ||
}); | ||
return this._sqsClient; | ||
} | ||
@@ -161,0 +166,0 @@ } |
{ | ||
"name": "ironium", | ||
"version": "6.0.0-pre", | ||
"version": "6.0.0", | ||
"scripts": { | ||
@@ -15,8 +15,8 @@ "lint": "eslint .", | ||
"dependencies": { | ||
"aws-sdk": "^2.45.0", | ||
"aws-sdk": "^2.45", | ||
"bluebird": "^3.5", | ||
"debug": "^2.6", | ||
"debug": "^3.0", | ||
"fivebeans": "^1.5", | ||
"iron-cache": "^0.3", | ||
"ms": "^0.7", | ||
"ms": "^2.0", | ||
"pretty-hrtime": "^1.0", | ||
@@ -26,8 +26,8 @@ "request": "^2.81" | ||
"devDependencies": { | ||
"eslint": "^3.17", | ||
"husky": "^0.13", | ||
"ioredis": "^2.3", | ||
"mocha": "^3.0", | ||
"eslint": "^4.6", | ||
"husky": "^0.14", | ||
"ioredis": "^3.1", | ||
"mocha": "^3.5", | ||
"nock": "^9.0", | ||
"timekeeper": "^1.0" | ||
"timekeeper": "^2.0" | ||
}, | ||
@@ -34,0 +34,0 @@ "homepage": "https://www.npmjs.com/package/ironium", |
@@ -553,3 +553,3 @@ # [Ironium](https://www.npmjs.com/package/ironium) | ||
([Travis](https://travis-ci.org/assaf/ironium) runs this), or specific | ||
files/tests with [Mocha](http://visionmedia.github.io/mocha/). | ||
files/tests with [Mocha](http://mochajs.org/). | ||
@@ -13,1 +13,4 @@ const File = require('fs'); | ||
}; | ||
module.exports.isAvailable = File.existsSync('iron.json'); |
@@ -79,1 +79,44 @@ 'use strict'; | ||
}); | ||
describe('Processing queues - AWS credentials temporarily unavailable', function() { | ||
let credentials; | ||
let refreshedCredentialsCount; | ||
before(setup); | ||
before(function() { | ||
refreshedCredentialsCount = 0; | ||
}); | ||
before(function() { | ||
credentials = { | ||
get(callback) { | ||
refreshedCredentialsCount++; | ||
callback(new Error('Getting credentials timed out')); | ||
} | ||
}; | ||
Ironium.configure({ credentials, region: 'us-east-1' }); | ||
}); | ||
before(function() { | ||
Ironium.eachJob('foo', Promise.resolve); | ||
}); | ||
before(function(done) { | ||
process.env.NODE_ENV = 'development'; | ||
Ironium.start(); | ||
setTimeout(done, 1000); | ||
}); | ||
it('should continue to refresh credentials', function() { | ||
assert(refreshedCredentialsCount > 1, `Expected refreshedCredentialsCount to be > 1, was ${refreshedCredentialsCount}`); | ||
}); | ||
after(function() { | ||
process.env.NODE_ENV = 'test'; | ||
Ironium.stop(); | ||
Ironium.configure({}); | ||
}); | ||
}); |
@@ -85,3 +85,3 @@ 'use strict'; | ||
describe('Running a job with errors - IronMQ', function() { | ||
(getIronMQConfig.isAvailable ? describe : describe.skip)('Running a job with errors - IronMQ', function() { | ||
let errorQueue; | ||
@@ -88,0 +88,0 @@ let runs; |
@@ -16,8 +16,9 @@ 'use strict'; | ||
// Count how many steps run | ||
const steps = new Set(); | ||
// Record jobs run | ||
const jobs = []; | ||
function recordTheStep(step) { | ||
return function() { | ||
steps.add(step); | ||
return function(job) { | ||
job.step = step; // eslint-disable-line no-param-reassign | ||
jobs.push(job); | ||
return Promise.resolve(); | ||
@@ -31,3 +32,3 @@ }; | ||
runMultipleQueue.eachJob(recordTheStep('C')); | ||
return runMultipleQueue.queueJob('job'); | ||
return runMultipleQueue.queueJob({ foo: '1' }); | ||
}); | ||
@@ -37,5 +38,11 @@ before(Ironium.runOnce); | ||
it('should run all three steps', function() { | ||
assert.equal(steps.size, 3); | ||
assert.equal(jobs.length, 3); | ||
}); | ||
it('should provide each handler with a copy of the payload', function() { | ||
assert.equal(jobs[0].step, 'A'); | ||
assert.equal(jobs[1].step, 'B'); | ||
assert.equal(jobs[2].step, 'C'); | ||
}); | ||
}); | ||
@@ -42,0 +49,0 @@ |
'use strict'; | ||
const assert = require('assert'); | ||
const Bluebird = require('bluebird'); | ||
const getIronMQConfig = require('../iron_mq_config'); | ||
const Ironium = require('../..'); | ||
const setup = require('../helpers'); | ||
const assert = require('assert'); | ||
const Bluebird = require('bluebird'); | ||
const Ironium = require('../..'); | ||
const setup = require('../helpers'); | ||
@@ -29,3 +28,3 @@ | ||
before(function() { | ||
const withoutConcurrency = Object.assign(getIronMQConfig(), { concurrency: 1 }); | ||
const withoutConcurrency = { concurrency: 1 }; | ||
Ironium.configure(withoutConcurrency); | ||
@@ -64,3 +63,3 @@ processSerialQueue = Ironium.queue(`process-serial-${Date.now()}`); | ||
before(function() { | ||
Ironium.configure(getIronMQConfig()); | ||
Ironium.configure({}); | ||
processParallelQueue = Ironium.queue(`process-parallel-${Date.now()}`); | ||
@@ -67,0 +66,0 @@ }); |
@@ -8,3 +8,3 @@ 'use strict'; | ||
describe('IronMQ', function() { | ||
(getIronMQConfig.isAvailable ? describe : describe.skip)('IronMQ', function() { | ||
let client; | ||
@@ -11,0 +11,0 @@ |
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
No v1
QualityPackage is not semver >=1. This means it is not stable and does not support ^ ranges.
Found 1 instance in 1 package
155073
3572
0
51
43
+ Addeddebug@3.2.7(transitive)
+ Addedms@2.1.3(transitive)
- Removeddebug@2.6.9(transitive)
- Removedms@0.7.32.0.0(transitive)
Updatedaws-sdk@^2.45
Updateddebug@^3.0
Updatedms@^2.0