@nerimity/mimiqueue
Advanced tools
Comparing version 2.0.3 to 2.0.4
{ | ||
"name": "@nerimity/mimiqueue", | ||
"version": "2.0.3", | ||
"version": "2.0.4", | ||
"description": "NodeJS group queuing library. Requires Redis.", | ||
@@ -5,0 +5,0 @@ "main": "dist/index.mjs", |
# Mimiqueue | ||
Free, open source NodeJS group queueing library with redis. | ||
Free, open source NodeJS group queueing library with redis. Currently being used in https://nerimity.com (My chat app) | ||
@@ -5,0 +5,0 @@ ### Features |
@@ -17,2 +17,3 @@ import { | ||
groupName?: string; | ||
id?: string; | ||
} | ||
@@ -32,2 +33,13 @@ | ||
const genId = async () => { | ||
return await generateId(opts.redisClient, opts.name); | ||
}; | ||
const getQueuePosition = async (id: string, groupName?: string) => { | ||
return await opts.redisClient.lPos( | ||
makeKey("mq", opts.name, groupName, "wait"), | ||
id | ||
); | ||
}; | ||
const pub = opts.redisClient.duplicate(); | ||
@@ -67,3 +79,3 @@ const sub = opts.redisClient.duplicate(); | ||
const add = async <T extends () => any>(func: T, addOpts?: AddOpts) => { | ||
const id = await generateId(opts.redisClient, opts.name); | ||
const id = addOpts?.id || (await genId()); | ||
@@ -93,3 +105,5 @@ await opts.redisClient.rPush( | ||
add, | ||
genId, | ||
getQueuePosition, | ||
}; | ||
}; |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
22628
16
295