node-resque
Advanced tools
Comparing version 5.0.2 to 5.1.0
@@ -21,3 +21,3 @@ const NodeResque = require('../../index.js') | ||
async afterPerform () { | ||
async beforePerform () { | ||
let key = this.key() | ||
@@ -24,0 +24,0 @@ await this.queueObject.connection.redis.del(key) |
@@ -300,3 +300,3 @@ const os = require('os') | ||
} else { | ||
cmd = 'ps -ef | awk \'{print $2}\'' | ||
cmd = 'ps -eo pid=' | ||
} | ||
@@ -303,0 +303,0 @@ |
@@ -6,3 +6,3 @@ { | ||
"license": "Apache-2.0", | ||
"version": "5.0.2", | ||
"version": "5.1.0", | ||
"homepage": "http://github.com/taskrabbit/node-resque", | ||
@@ -9,0 +9,0 @@ "repository": { |
@@ -81,3 +81,3 @@ # node-resque: The best background jobs in node. | ||
// ////////////////////// | ||
// REGESTER FOR EVENTS // | ||
// REGISTER FOR EVENTS // | ||
// ////////////////////// | ||
@@ -470,3 +470,3 @@ | ||
- Most of this code was inspired by / stolen from [coffee-resque](https://npmjs.org/package/coffee-resque) and [coffee-resque-scheduler](https://github.com/leeadkins/coffee-resque-scheduler). Thanks! | ||
- This Resque package aims to be fully compatible with [Ruby's Resque](https://github.com/resque/resque) and implamentations of [Resque Scheduler](https://github.com/resque/resque-scheduler). Other packages from other langauges may conflict. | ||
- This Resque package aims to be fully compatible with [Ruby's Resque](https://github.com/resque/resque) and implementations of [Resque Scheduler](https://github.com/resque/resque-scheduler). Other packages from other langauges may conflict. | ||
- If you are looking for a UI to manage your Resque instances in nodejs, check out [ActionHero's Resque UI](https://github.com/evantahler/ah-resque-ui) |
@@ -20,3 +20,3 @@ const path = require('path') | ||
'uniqueJob': { | ||
plugins: ['QueueLock', 'DelayQueueLock'], | ||
plugins: ['DelayQueueLock'], | ||
pluginOptions: { queueLock: {}, delayQueueLock: {} }, | ||
@@ -23,0 +23,0 @@ perform: async (a, b) => { |
@@ -20,10 +20,2 @@ const path = require('path') | ||
} | ||
}, | ||
'uniqueJob': { | ||
plugins: ['QueueLock', 'DelayQueueLock'], | ||
pluginOptions: { queueLock: {}, delayQueueLock: {} }, | ||
perform: (a, b) => { | ||
let answer = a + b | ||
return answer | ||
} | ||
} | ||
@@ -30,0 +22,0 @@ } |
@@ -8,9 +8,15 @@ const path = require('path') | ||
class NeverRunPlugin extends NodeResque.Plugin { | ||
beforePerform () { return false } | ||
} | ||
const jobs = { | ||
'uniqueJob': { | ||
plugins: ['QueueLock', 'DelayQueueLock'], | ||
plugins: ['QueueLock'], | ||
pluginOptions: { queueLock: {}, delayQueueLock: {} }, | ||
perform: (a, b) => { | ||
return (a + b) | ||
} | ||
perform: (a, b) => (a + b) | ||
}, | ||
'blockingJob': { | ||
plugins: ['QueueLock', NeverRunPlugin], | ||
perform: (a, b) => (a + b) | ||
} | ||
@@ -48,3 +54,40 @@ } | ||
}) | ||
describe('with worker', () => { | ||
let worker | ||
beforeEach(async () => { | ||
worker = new NodeResque.Worker({ | ||
connection: specHelper.cleanConnectionDetails(), | ||
timeout: specHelper.timeout, | ||
queues: specHelper.queue | ||
}, jobs) | ||
worker.on('error', (error) => { throw error }) | ||
await worker.connect() | ||
}) | ||
it('will remove a lock on a job when the job has been worked', async () => { | ||
const enqueue = await queue.enqueue(specHelper.queue, 'uniqueJob', [1, 2]) | ||
enqueue.should.equal(true) | ||
await worker.start() | ||
await worker.end() | ||
const result = await specHelper.redis.keys(specHelper.namespace + ':lock*') | ||
result.should.have.lengthOf(0) | ||
}) | ||
it('will remove a lock on a job if a plugin does not run the job', async () => { | ||
const enqueue = await queue.enqueue(specHelper.queue, 'blockingJob', [1, 2]) | ||
enqueue.should.equal(true) | ||
await worker.start() | ||
await worker.end() | ||
const result = await specHelper.redis.keys(specHelper.namespace + ':lock*') | ||
result.should.have.lengthOf(0) | ||
}) | ||
}) | ||
}) | ||
}) |
518822
3452
45