Skip to content

Commit 6b94f88

Browse files
committed
feat: add support for bullmq v6 and postgresql
1 parent d9b6b83 commit 6b94f88

20 files changed

Lines changed: 3485 additions & 1324 deletions

lib/cmd.ts

Lines changed: 62 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -79,6 +79,41 @@ export const run = (name: string, version: string) => {
7979
"file with queues to monitor"
8080
).conflicts("queues")
8181
)
82+
// PostgreSQL backend options (BullMQ v6+)
83+
.addOption(
84+
new Option(
85+
"--pg-host [host]",
86+
"PostgreSQL host (enables PG backend instead of Redis)"
87+
)
88+
.env("PG_HOST")
89+
.conflicts(["uri", "nodes", "sentinels"])
90+
)
91+
.option(
92+
"--pg-port [port]",
93+
"PostgreSQL port [5432]",
94+
process.env.PG_PORT || "5432"
95+
)
96+
.option(
97+
"--pg-database [database]",
98+
"PostgreSQL database name",
99+
process.env.PG_DATABASE
100+
)
101+
.option(
102+
"--pg-user [user]",
103+
"PostgreSQL user",
104+
process.env.PG_USER
105+
)
106+
.option(
107+
"--pg-password [password]",
108+
"PostgreSQL password",
109+
process.env.PG_PASSWORD
110+
)
111+
.option(
112+
"--pg-schema [schema]",
113+
"PostgreSQL schema for BullMQ tables [bullmq]",
114+
process.env.PG_SCHEMA
115+
)
116+
.option("--pg-ssl", "enable SSL for PostgreSQL connection")
82117
.parse(process.argv);
83118

84119
const options = program.opts();
@@ -105,6 +140,22 @@ export const run = (name: string, version: string) => {
105140
process.exit(1);
106141
}
107142

143+
// Validate PostgreSQL options when PG backend is selected
144+
if (options.pgHost) {
145+
if (!options.pgDatabase) {
146+
console.error(
147+
red("ERROR: --pg-database is required when using PostgreSQL backend")
148+
);
149+
process.exit(1);
150+
}
151+
if (!options.pgUser) {
152+
console.error(
153+
red("ERROR: --pg-user is required when using PostgreSQL backend")
154+
);
155+
process.exit(1);
156+
}
157+
}
158+
108159
const queueNames = options.queuesFile
109160
? parseQueuesFile(options.queuesFile)
110161
: options.queues
@@ -152,6 +203,17 @@ export const run = (name: string, version: string) => {
152203
team: options.team,
153204
nodes: options.nodes ? options.nodes.split(",") : undefined,
154205
queueNames,
206+
pgOpts: options.pgHost
207+
? {
208+
host: options.pgHost,
209+
port: parseInt(options.pgPort, 10),
210+
database: options.pgDatabase,
211+
user: options.pgUser,
212+
password: options.pgPassword,
213+
schema: options.pgSchema,
214+
ssl: options.pgSsl || false,
215+
}
216+
: undefined,
155217
});
156218
});
157219

lib/interfaces/integration.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ export interface Integration {
66
responders: Responders;
77
createQueue: (
88
foundQueue: FoundQueue,
9-
redisOpts: RedisOptions,
9+
redisOpts: RedisOptions | undefined,
1010
nodes?: string[]
1111
) => any;
1212
}

0 commit comments

Comments
 (0)