MCPcopy
hub / github.com/OptimalBits/bull / Queue

Function Queue

lib/queue.js:85–287  ·  view source on GitHub ↗
(name, url, opts)

Source from the content-addressed store, hash-verified

83
84// Queue(name: string, url?, opts?)
85const Queue = function Queue(name, url, opts) {
86 if (!(this instanceof Queue)) {
87 return new Queue(name, url, opts);
88 }
89
90 if (_.isString(url)) {
91 const clonedOpts = _.cloneDeep(opts || {});
92 opts = {
93 ...clonedOpts,
94 redis: {
95 ...redisOptsFromUrl(url),
96 ...clonedOpts.redis
97 }
98 };
99 } else {
100 opts = _.cloneDeep(url || {});
101 }
102
103 if (!_.isObject(opts)) {
104 throw TypeError('Options must be a valid object');
105 }
106
107 if (opts.limiter) {
108 if (opts.limiter.max && opts.limiter.duration) {
109 this.limiter = opts.limiter;
110 } else {
111 throw new TypeError('Limiter requires `max` and `duration` options');
112 }
113 }
114
115 if (opts.defaultJobOptions) {
116 this.defaultJobOptions = opts.defaultJobOptions;
117 }
118
119 this.name = name;
120 this.token = uuid.v4();
121
122 opts.redis = {
123 enableReadyCheck: false,
124 ...(_.isString(opts.redis)
125 ? { ...redisOptsFromUrl(opts.redis) }
126 : opts.redis)
127 };
128
129 _.defaults(opts.redis, {
130 port: 6379,
131 host: '127.0.0.1',
132 db: opts.redis.db || opts.redis.DB,
133 retryStrategy: function(times) {
134 return Math.min(Math.exp(times), 20000);
135 }
136 });
137
138 this.keyPrefix = opts.redis.keyPrefix || opts.prefix || 'bull';
139
140 //
141 // We cannot use ioredis keyPrefix feature since we
142 // create keys dynamically in lua scripts.

Callers

nothing calls this directly

Calls 6

redisOptsFromUrlFunction · 0.85
redisClientGetterFunction · 0.85
loadCommandsFunction · 0.85
getRedisVersionFunction · 0.85
onMethod · 0.80
toKeyMethod · 0.80

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…