Skip to content

Commit

Permalink
Merge pull request #214 from taskrabbit/empty-namespace
Browse files Browse the repository at this point in the history
allow for empty namespaces
  • Loading branch information
evantahler authored Sep 19, 2017
2 parents 0750ead + 9c2ec66 commit ca14dd6
Show file tree
Hide file tree
Showing 5 changed files with 14 additions and 2 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
[![Build Status](https://secure.travis-ci.org/taskrabbit/node-resque.png?branch=master)](http://travis-ci.org/taskrabbit/node-resque)

## Version Notes
* ‼️ Version 6+ of Node Resque uses async/await. There is no upgrade path from previous versions. Node v8.0.0+ is required.
* ‼️ Version 5+ of Node Resque uses async/await. There is no upgrade path from previous versions. Node v8.0.0+ is required.

## Usage

Expand Down
3 changes: 2 additions & 1 deletion changelog
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
- dropped support for fakeredis; you must use a redis connection which supports promises
- async!!!
- capitol names for all classes
- plugin lifecycles are now cammel case: beforeEnqueue, afterEnqueue, beforePerform, afterPerform
- plugin lifecycles are now camel case: beforeEnqueue, afterEnqueue, beforePerform, afterPerform
- plugin lifecycle methods are now async methods, with no callback
- plugins now inherit from NodeResque.Plugin
- allow for empty/null namespaces (to match sidekiq's default)
1 change: 1 addition & 0 deletions lib/connection.js
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,7 @@ class Connection extends EventEmitter {
let args
args = (arguments.length >= 1 ? [].slice.call(arguments, 0) : [])
args.unshift(this.options.namespace)
args = args.filter((e) => { return String(e).trim() })
return args.join(':')
}
}
Expand Down
1 change: 1 addition & 0 deletions lib/queue.js
Original file line number Diff line number Diff line change
Expand Up @@ -185,6 +185,7 @@ class Queue extends EventEmitter {
for (var i = 0; i < keys.length; i++) {
var k = keys[i]
k = k.replace(this.connection.key(''), '')
if (k[0] === ':') { k = k.substr(1) }
data[k] = values[i]
}

Expand Down
9 changes: 9 additions & 0 deletions test/core/connection.js
Original file line number Diff line number Diff line change
Expand Up @@ -45,4 +45,13 @@ describe('connection', () => {
connection.key('thing').should.equal(specHelper.namespace + ':thing')
connection.end()
})

it('removes empty namespace from generated key', async () => {
let connectionDetails = specHelper.cleanConnectionDetails()
connectionDetails['namespace'] = ''
let connection = new NodeResque.Connection(connectionDetails)
await connection.connect()
connection.key('thing').should.equal('thing')
connection.end()
})
})

0 comments on commit ca14dd6

Please sign in to comment.