Trying to understand the typeof RedisConnection
signature on Queue constructor
#1108
-
I'm trying to create a shared redis connection for a small The docs which appear to be out of date seem to instruct creation of a new This causes a When I look through the code it seems like the new approach is to (maybe?) pass in a import { RedisConnection, Queue } from "bullmq"
import { redisOptions, queueOptions, queueName } from "./config"
const connection = new RedisConnection(redisOptions, true)
const queue = new Queue(queueName, queueOptions, connection) However the constructor signature for https://github.com/taskforcesh/bullmq/blob/master/docs/gitbook/api/bullmq.queue._constructor_.md
This leads me to think that there is either two possibilities:
constructor(name: string, opts?: QueueOptions, Connection?: RedisConnection); rather than the current constructor(name: string, opts?: QueueOptions, Connection?: typeof RedisConnection); If the answer is 1) then any tips to get back on the right path would be awesome! |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment
-
The documentation is correct, you do not need to use the third argument, that is only used for implementing extensions that need different features than the ones provided by the standard RedisConnection class. You just need to pass an existing redis client as connection and then the class will reuse it as much as it can: const connection = new Redis();
const queue = new Queue('myqueue', { connection }); |
Beta Was this translation helpful? Give feedback.
The documentation is correct, you do not need to use the third argument, that is only used for implementing extensions that need different features than the ones provided by the standard RedisConnection class. You just need to pass an existing redis client as connection and then the class will reuse it as much as it can: