Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added makeTaskId function #79

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 5 additions & 2 deletions index.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -42,10 +42,12 @@ class RedisSMQ extends EventEmitter
port: 6379
options: {}
client: null
ns: "rsmq"
ns: "rsmq",
makeTaskId: (uuid) => uuid,
, options

@redisns = opts.ns + ":"
@makeTaskId = opts.makeTaskId
if opts.client?.constructor?.name is "RedisClient"
@redis = opts.client
else
Expand Down Expand Up @@ -485,7 +487,8 @@ class RedisSMQ extends EventEmitter
if q.maxsize isnt -1 and options.message.length > q.maxsize
@_handleError(cb, "messageTooLong")
return

# Makr final task id
q.uid = @makeTaskId(q.uid, options.message)
# Ready to store the message
mc = [
["zadd", "#{@redisns}#{options.qname}", q.ts + options.delay * 1000, q.uid]
Expand Down
10 changes: 9 additions & 1 deletion index.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 6 additions & 0 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,8 @@
},
"scripts": {
"build": "coffee -cb index.coffee test/test.coffee",
"test": "mocha ./test/test.js"
"test": "mocha ./test/test.js",
"pretest": "npm run build"
},
"dependencies": {
"@types/redis": "^2.8.0",
Expand Down