Skip to content

Commit fb9a649

Browse files
committed
test: add shared redis instances in examples
1 parent 4156a2a commit fb9a649

File tree

3 files changed

+33
-9
lines changed

3 files changed

+33
-9
lines changed

example/bull.js

Lines changed: 29 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
const express = require('express');
2+
const IORedis = require('ioredis');
23
const path = require('path');
34
const Arena = require('../');
45
const Bull = require('bull');
@@ -8,7 +9,19 @@ const HTTP_SERVER_PORT = 4735;
89
const REDIS_SERVER_PORT = 6379;
910

1011
async function main() {
11-
const queue = new Bull('name_of_my_queue', {
12+
const queueName1 = 'name_of_my_queue_1';
13+
const connection = new IORedis({port: REDIS_SERVER_PORT});
14+
15+
const createClient = (type) => {
16+
switch (type) {
17+
case 'client':
18+
return connection;
19+
default:
20+
return new IORedis({port: REDIS_SERVER_PORT});
21+
}
22+
};
23+
24+
const queue = new Bull(queueName1, {
1225
redis: {
1326
port: REDIS_SERVER_PORT,
1427
},
@@ -42,7 +55,7 @@ async function main() {
4255
queues: [
4356
{
4457
// Required for each queue definition.
45-
name: 'name_of_my_queue',
58+
name: queueName1,
4659

4760
// User-readable display name for the host. Required.
4861
hostId: 'Queue Server 1',
@@ -55,6 +68,20 @@ async function main() {
5568
port: REDIS_SERVER_PORT,
5669
},
5770
},
71+
{
72+
// Required for each queue definition.
73+
name: 'name_of_my_queue_2',
74+
75+
// User-readable display name for the host. Required.
76+
hostId: 'Queue Server 2',
77+
78+
// Queue type (Bull or Bee - default Bull).
79+
type: 'bull',
80+
81+
redis: {
82+
createClient,
83+
},
84+
},
5885
],
5986
customJsPath: 'http://localhost:4735/example.js',
6087
},

example/bullmq.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
const Arena = require('../');
2+
const IORedis = require('ioredis');
23
const {Queue, Worker, FlowProducer} = require('bullmq');
34

45
// Select ports that are unlikely to be used by other services a developer might be running locally.
@@ -9,6 +10,8 @@ async function main() {
910
const queueName = 'name_of_my_queue';
1011
const parentQueueName = 'name_of_my_parent_queue';
1112

13+
const connection = new IORedis({port: REDIS_SERVER_PORT});
14+
1215
const queue = new Queue(queueName, {
1316
connection: {port: REDIS_SERVER_PORT},
1417
});
@@ -87,10 +90,7 @@ async function main() {
8790
// Queue type (Bull or Bullmq or Bee - default Bull).
8891
type: 'bullmq',
8992

90-
redis: {
91-
// host: 'localhost',
92-
port: REDIS_SERVER_PORT,
93-
},
93+
redis: connection,
9494
},
9595
{
9696
// Required for each queue definition.

src/server/queue/index.js

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -106,9 +106,6 @@ class Queues {
106106
queue = new Bee(name, options);
107107
queue.IS_BEE = true;
108108
} else if (isBullMQ) {
109-
if (queueConfig.createClient)
110-
options.createClient = queueConfig.createClient;
111-
112109
const {BullMQ} = this._config;
113110
const {redis, ...rest} = options;
114111
queue = new BullMQ(name, {

0 commit comments

Comments
 (0)