Removing old redisProtocol string - it is causing confusion and should not be necessary.
This commit is contained in:
parent
86f7bd192f
commit
f8f1ec4ce9
|
@ -6,7 +6,6 @@ import BullQueue, { QueueOptions } from "bull"
|
|||
import { addListeners, StalledFn } from "./listeners"
|
||||
import { Duration } from "../utils"
|
||||
import * as timers from "../timers"
|
||||
import * as Redis from "ioredis"
|
||||
|
||||
// the queue lock is held for 5 minutes
|
||||
const QUEUE_LOCK_MS = Duration.fromMinutes(5).toMs()
|
||||
|
@ -27,9 +26,9 @@ export function createQueue<T>(
|
|||
jobQueue: JobQueue,
|
||||
opts: { removeStalledCb?: StalledFn } = {}
|
||||
): BullQueue.Queue<T> {
|
||||
const { opts: redisOpts, redisProtocolUrl } = getRedisOptions()
|
||||
const { opts: redisOpts } = getRedisOptions()
|
||||
const queueConfig: QueueOptions = {
|
||||
redis: redisProtocolUrl! || (redisOpts as Redis.RedisOptions),
|
||||
redis: redisOpts,
|
||||
settings: {
|
||||
maxStalledCount: 0,
|
||||
lockDuration: QUEUE_LOCK_MS,
|
||||
|
|
|
@ -91,12 +91,10 @@ function init(selectDb = DEFAULT_SELECT_DB) {
|
|||
if (client) {
|
||||
client.disconnect()
|
||||
}
|
||||
const { redisProtocolUrl, opts, host, port } = getRedisOptions()
|
||||
const { opts, host, port } = getRedisOptions()
|
||||
|
||||
if (CLUSTERED) {
|
||||
client = new RedisCore.Cluster([{ host, port }], opts)
|
||||
} else if (redisProtocolUrl) {
|
||||
client = new RedisCore(redisProtocolUrl)
|
||||
} else {
|
||||
client = new RedisCore(opts)
|
||||
}
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
import env from "../environment"
|
||||
import * as Redis from "ioredis"
|
||||
|
||||
const SLOT_REFRESH_MS = 2000
|
||||
const CONNECT_TIMEOUT_MS = 10000
|
||||
|
@ -74,28 +75,29 @@ export function getRedisOptions() {
|
|||
}
|
||||
const [host, port] = url.split(":")
|
||||
|
||||
let redisProtocolUrl
|
||||
|
||||
// fully qualified redis URL
|
||||
if (/rediss?:\/\//.test(env.REDIS_URL)) {
|
||||
redisProtocolUrl = env.REDIS_URL
|
||||
}
|
||||
|
||||
const opts: any = {
|
||||
let redisOpts: Redis.RedisOptions = {
|
||||
connectTimeout: CONNECT_TIMEOUT_MS,
|
||||
port: parseInt(port),
|
||||
host,
|
||||
password,
|
||||
}
|
||||
let opts: Redis.ClusterOptions | Redis.RedisOptions = redisOpts
|
||||
if (env.REDIS_CLUSTERED) {
|
||||
opts.redisOptions = {}
|
||||
opts.redisOptions.tls = {}
|
||||
opts.redisOptions.password = password
|
||||
opts.slotsRefreshTimeout = SLOT_REFRESH_MS
|
||||
opts.dnsLookup = (address: string, callback: any) => callback(null, address)
|
||||
} else {
|
||||
opts.host = host
|
||||
opts.port = port
|
||||
opts.password = password
|
||||
opts = {
|
||||
connectTimeout: CONNECT_TIMEOUT_MS,
|
||||
redisOptions: {
|
||||
...redisOpts,
|
||||
tls: {},
|
||||
},
|
||||
slotsRefreshTimeout: SLOT_REFRESH_MS,
|
||||
dnsLookup: (address: string, callback: any) => callback(null, address),
|
||||
} as Redis.ClusterOptions
|
||||
}
|
||||
return {
|
||||
opts,
|
||||
host,
|
||||
port: parseInt(port),
|
||||
}
|
||||
return { opts, host, port: parseInt(port), redisProtocolUrl }
|
||||
}
|
||||
|
||||
export function addDbPrefix(db: string, key: string) {
|
||||
|
|
Loading…
Reference in New Issue